mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Removed deprecated code
This commit is contained in:
parent
792bfe1ccc
commit
54a2a6a19c
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Source\Generator;
|
||||
|
||||
use App\Entity\SourceInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractGenerator
|
||||
{
|
||||
/**
|
||||
* @var SourceInterface
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
public function __construct(Request $request, SourceInterface $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
$this->request = $request;
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Source\Generator;
|
||||
|
||||
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
||||
use Symfony\Component\Serializer\Encoder\YamlEncoder;
|
||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||
use Symfony\Component\Serializer\Encoder\CsvEncoder;
|
||||
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SerializeGenerator extends AbstractGenerator
|
||||
{
|
||||
const SERIALIZABLE_FORMATS = [
|
||||
'xml',
|
||||
'json',
|
||||
'csv',
|
||||
'yaml',
|
||||
];
|
||||
|
||||
public function serialize(): string
|
||||
{
|
||||
$encoders = [new XmlEncoder(), new JsonEncoder(), new YamlEncoder(), new CsvEncoder()];
|
||||
$normalizer = new ObjectNormalizer();
|
||||
$normalizer->setCircularReferenceLimit(0);
|
||||
$normalizer->setCircularReferenceHandler(function ($object) {
|
||||
return $object->getId();
|
||||
});
|
||||
$serializer = new Serializer([$normalizer], $encoders);
|
||||
|
||||
return $serializer->serialize($this->source, $this->request->getRequestFormat());
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Source\Generator;
|
||||
|
||||
use App\Entity\SourceInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use App\Creator\Factory\Template\SourceTemplateFactory;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class TemplateGenerator 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
|
||||
{
|
||||
$templatePathFactory = new SourceTemplateFactory($this->source, $this->request);
|
||||
|
||||
return $this->twig->render($templatePathFactory->getTemplatePath(), ['source' => $this->source]);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user