Removed deprecated code

This commit is contained in:
Kevin Frantz 2018-09-16 18:00:11 +02:00
parent 792bfe1ccc
commit 54a2a6a19c
4 changed files with 0 additions and 130 deletions

View File

@ -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;
}
}

View File

@ -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());
}
}

View File

@ -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();
}
}

View File

@ -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]);
}
}