Completed
Pull Request — master (#67)
by Ross
05:39
created

TacticianBundle::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace League\Tactician\Bundle;
4
5
use League\Tactician\Bundle\DependencyInjection\HandlerMapping\ClassNameMapping;
6
use League\Tactician\Bundle\DependencyInjection\HandlerMapping\HandlerMapping;
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
12
class TacticianBundle extends Bundle
13
{
14
    /**
15
     * @var HandlerMapping
16
     */
17
    private $handlerMapping;
18
19
    public function __construct(HandlerMapping $handlerMapping = null)
20
    {
21
        if ($handlerMapping == null) {
22
            $handlerMapping = new ClassNameMapping();
23
        }
24
25
        $this->handlerMapping = $handlerMapping;
26
    }
27
28
29
    public function build(ContainerBuilder $container)
30
    {
31
        parent::build($container);
32
        $container->addCompilerPass(new Compiler\DoctrineMiddlewarePass());
33
        $container->addCompilerPass(new Compiler\ValidatorMiddlewarePass());
34
        $container->addCompilerPass(new Compiler\SecurityMiddlewarePass());
35
        $container->addCompilerPass(new Compiler\CommandHandlerPass($this->handlerMapping));
36
    }
37
38
    public function getContainerExtension()
39
    {
40
        return new TacticianExtension();
41
    }
42
}
43