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.     /**
  26.      * @return void
  27.      */
  28.     public function build(ContainerBuilder $container)
  29.     {
  30.         parent::build($container);
  31.         $container->addCompilerPass(new Compiler\DoctrineMiddlewarePass());
  32.         $container->addCompilerPass(new Compiler\ValidatorMiddlewarePass());
  33.         $container->addCompilerPass(new Compiler\SecurityMiddlewarePass());
  34.         $container->addCompilerPass(new Compiler\CommandHandlerPass($this->handlerMapping));
  35.     }
  36.     public function getContainerExtension(): ExtensionInterface
  37.     {
  38.         return new TacticianExtension();
  39.     }
  40.     public static function defaultMappingStrategy(): HandlerMapping
  41.     {
  42.         return new CompositeMapping(new TypeHintMapping(), new ClassNameMapping());
  43.     }
  44. }