vendor/league/tactician-bundle/src/TacticianBundle.php line 15

Open in your IDE?
  1. <?php
  2. namespace League\Tactician\Bundle;
  3. use League\Tactician\Bundle\DependencyInjection\HandlerMapping\ClassNameMapping;
  4. use League\Tactician\Bundle\DependencyInjection\HandlerMapping\CompositeMapping;
  5. use League\Tactician\Bundle\DependencyInjection\HandlerMapping\HandlerMapping;
  6. use League\Tactician\Bundle\DependencyInjection\HandlerMapping\TypeHintMapping;
  7. use Symfony\Component\DependencyInjection\ContainerBuilder;
  8. use League\Tactician\Bundle\DependencyInjection\Compiler;
  9. use League\Tactician\Bundle\DependencyInjection\TacticianExtension;
  10. use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
  11. use Symfony\Component\HttpKernel\Bundle\Bundle;
  12. class TacticianBundle extends Bundle
  13. {
  14.     /**
  15.      * @var HandlerMapping
  16.      */
  17.     private $handlerMapping;
  18.     public function __construct(HandlerMapping $handlerMapping null)
  19.     {
  20.         if ($handlerMapping === null) {
  21.             $handlerMapping = static::defaultMappingStrategy();
  22.         }
  23.         $this->handlerMapping $handlerMapping;
  24.     }
  25.     public function build(ContainerBuilder $container)
  26.     {
  27.         parent::build($container);
  28.         $container->addCompilerPass(new Compiler\DoctrineMiddlewarePass());
  29.         $container->addCompilerPass(new Compiler\ValidatorMiddlewarePass());
  30.         $container->addCompilerPass(new Compiler\SecurityMiddlewarePass());
  31.         $container->addCompilerPass(new Compiler\CommandHandlerPass($this->handlerMapping));
  32.     }
  33.     public function getContainerExtension(): ExtensionInterface
  34.     {
  35.         return new TacticianExtension();
  36.     }
  37.     public static function defaultMappingStrategy(): HandlerMapping
  38.     {
  39.         return new CompositeMapping(new TypeHintMapping(), new ClassNameMapping());
  40.     }
  41. }