can get format list
This commit is contained in:
parent
34b2b0b061
commit
4c91b0d699
@ -22,19 +22,29 @@ class RendererBridge
|
||||
const FORMAT_CSV = 'CSV';
|
||||
const FORMAT_PRETTY = 'Pretty';
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRendererList(): array
|
||||
{
|
||||
return [
|
||||
self::FORMAT_CSV => oxNew(Csv::class),
|
||||
self::FORMAT_PRETTY => oxNew(Pretty::class)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $format
|
||||
*
|
||||
* @throws NoSuitableRendererException
|
||||
* @return RendererInterface
|
||||
* @throws NoSuitableRendererException
|
||||
*/
|
||||
public function getRenderer($format = self::FORMAT_CSV): RendererInterface
|
||||
public function getRenderer(string $format = self::FORMAT_CSV): RendererInterface
|
||||
{
|
||||
switch ($format) {
|
||||
case self::FORMAT_CSV:
|
||||
return oxNew(Csv::class);
|
||||
case self::FORMAT_PRETTY:
|
||||
return oxNew(Pretty::class);
|
||||
$rendererList = $this->getRendererList();
|
||||
|
||||
if (in_array($format, array_keys($rendererList))) {
|
||||
return $rendererList[$format];
|
||||
}
|
||||
|
||||
/** @var NoSuitableRendererException $e */
|
||||
|
Loading…
Reference in New Issue
Block a user