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

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\HttpKernel\Bundle\Bundle;
  11. class TacticianBundle extends Bundle
  12. {
  13.     /**
  14.      * @var HandlerMapping
  15.      */
  16.     private $handlerMapping;
  17.     public function __construct(HandlerMapping $handlerMapping null)
  18.     {
  19.         if ($handlerMapping === null) {
  20.             $handlerMapping = static::defaultMappingStrategy();
  21.         }
  22.         $this->handlerMapping $handlerMapping;
  23.     }
  24.     public function build(ContainerBuilder $container)
  25.     {
  26.         parent::build($container);
  27.         $container->addCompilerPass(new Compiler\DoctrineMiddlewarePass());
  28.         $container->addCompilerPass(new Compiler\ValidatorMiddlewarePass());
  29.         $container->addCompilerPass(new Compiler\SecurityMiddlewarePass());
  30.         $container->addCompilerPass(new Compiler\CommandHandlerPass($this->handlerMapping));
  31.     }
  32.     public function getContainerExtension()
  33.     {
  34.         return new TacticianExtension();
  35.     }
  36.     public static function defaultMappingStrategy(): HandlerMapping
  37.     {
  38.         return new CompositeMapping(new TypeHintMapping(), new ClassNameMapping());
  39.     }
  40. }