Почистил мусор

master
Sipachev Igor 3 years ago
parent f0683ef40d
commit 4083f1937e
  1. 2
      src/DependencyInjection/RequestExtension.php
  2. 7
      src/EventListener/RequestListener.php
  3. 7
      src/Resources/config/services.yaml
  4. 13
      src/Service/Transformer/AbstractTransformer.php
  5. 1
      src/Service/Transformer/EntityTransformer.php
  6. 23
      src/Service/Transformer/ServiceResolver.php

@ -14,7 +14,5 @@ class RequestExtension extends Extension
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yaml');
// $container->findTaggedServiceIds(AbstractTransformer::class);
}
}

@ -17,15 +17,8 @@ use Symfony\Component\Validator\Validation;
// todo базовая заготовка. Требуется рефакторинг
class RequestListener
{
public function __construct(
private ServiceResolver $serviceResolver
) {}
public function onKernelRequest(RequestEvent $event)
{
$storage = TransformerResolverStorage::getInstance();
$storage->add(ServiceResolver::TYPE, $this->serviceResolver);
$request = $event->getRequest();
$controller = $request->get('_controller');
if (is_string($controller)) {

@ -11,10 +11,3 @@ services:
Rinsvent\RequestBundle\Service\Transformer\:
resource: '../../../src/Service/Transformer'
Rinsvent\RequestBundle\Service\Transformer\ServiceResolver:
bind:
$transformerLocator: !tagged_locator { tag: 'rinsvent.transformer', index_by: 'key', default_index_method: 'getLocatorKey' }
_instanceof:
Rinsvent\RequestBundle\Service\Transformer\AbstractTransformer:
tags: [ 'rinsvent.transformer' ]

@ -1,13 +0,0 @@
<?php
namespace Rinsvent\RequestBundle\Service\Transformer;
use Rinsvent\Data2DTO\Transformer\TransformerInterface;
abstract class AbstractTransformer implements TransformerInterface
{
public static function getLocatorKey()
{
return static::class;
}
}

@ -4,6 +4,7 @@ namespace Rinsvent\RequestBundle\Service\Transformer;
use Doctrine\ORM\EntityManagerInterface;
use Rinsvent\Data2DTO\Transformer\Meta;
use Rinsvent\Data2DTOBundle\Service\AbstractTransformer;
class EntityTransformer extends AbstractTransformer
{

@ -1,23 +0,0 @@
<?php
namespace Rinsvent\RequestBundle\Service\Transformer;
use Rinsvent\Data2DTO\Resolver\TransformerResolverInterface;
use Rinsvent\Data2DTO\Transformer\Meta;
use Rinsvent\Data2DTO\Transformer\TransformerInterface;
use Symfony\Component\DependencyInjection\ServiceLocator;
class ServiceResolver implements TransformerResolverInterface
{
public const TYPE = 'service';
public function __construct(
private ServiceLocator $transformerLocator
) {}
public function resolve(Meta $meta): TransformerInterface
{
$transformerClass = $meta::class . 'Transformer';
return $this->transformerLocator->get($transformerClass);
}
}
Loading…
Cancel
Save