can get format list

This commit is contained in:
Daniel Seifert 2021-07-14 12:22:01 +02:00
parent 34b2b0b061
commit 4c91b0d699
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F

View File

@ -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 */