mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-10-11 18:18:09 +02:00
Optimized implementation of format types
This commit is contained in:
35
application/src/Source/Generator/StringGenerator.php
Normal file
35
application/src/Source/Generator/StringGenerator.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Source\Generator;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use App\Entity\SourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class StringGenerator extends AbstractGenerator
|
||||
{
|
||||
/**
|
||||
* @var \Twig_Environment
|
||||
*/
|
||||
protected $twig;
|
||||
|
||||
public function __construct(Request $request, SourceInterface $source, \Twig_Environment $twig)
|
||||
{
|
||||
parent::__construct($request, $source);
|
||||
$this->twig = $twig;
|
||||
}
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
if (in_array($this->request->getRequestFormat(), SerializeGenerator::SERIALIZABLE_FORMATS)) {
|
||||
$serializeGenerator = new SerializeGenerator($this->request, $this->source);
|
||||
|
||||
return $serializeGenerator->serialize();
|
||||
}
|
||||
$templateGenerator = new TemplateGenerator($this->request, $this->source, $this->twig);
|
||||
|
||||
return $templateGenerator->render();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user