Completed
Branch master (c0d8ef)
by Yaroslav
06:36
created

YarhonRouteGuardBundle::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 17
rs 10
c 0
b 0
f 0
ccs 9
cts 9
cp 1
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 *
5
 * (c) Yaroslav Honcharuk <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Yarhon\RouteGuardBundle;
12
13
use Symfony\Component\HttpKernel\Bundle\Bundle;
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
16
use Yarhon\RouteGuardBundle\DependencyInjection\Compiler\SymfonySecurityBundlePass;
17
use Yarhon\RouteGuardBundle\DependencyInjection\Compiler\SensioFrameworkExtraBundlePass;
18
use Yarhon\RouteGuardBundle\DependencyInjection\Compiler\TwigBundlePass;
19
use Yarhon\RouteGuardBundle\DependencyInjection\Compiler\ContainerClassMapPass;
20
use Yarhon\RouteGuardBundle\DependencyInjection\Compiler\InjectTaggedServicesPass;
21
use Yarhon\RouteGuardBundle\DependencyInjection\Container\ForeignExtensionAccessor;
22
use Yarhon\RouteGuardBundle\DependencyInjection\Container\ClassMapBuilder;
23
24
/**
25
 * @author Yaroslav Honcharuk <[email protected]>
26
 */
27
class YarhonRouteGuardBundle extends Bundle
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32 1
    public function build(ContainerBuilder $container)
33
    {
34 1
        parent::build($container);
35
36 1
        $foreignExtensionAccessor = new ForeignExtensionAccessor();
37 1
        $classMapBuilder = new ClassMapBuilder();
38
39
        // We use same type and priority as are used for \Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExtensionPass
40 1
        $container->addCompilerPass(new TwigBundlePass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
41
42 1
        $container->addCompilerPass(new SymfonySecurityBundlePass($foreignExtensionAccessor), PassConfig::TYPE_BEFORE_REMOVING, 100);
43 1
        $container->addCompilerPass(new SensioFrameworkExtraBundlePass(), PassConfig::TYPE_BEFORE_REMOVING, 101);
44
45 1
        $container->addCompilerPass(new InjectTaggedServicesPass(), PassConfig::TYPE_BEFORE_REMOVING, 0);
46
47
        // We need only public services for the class map, so we include this pass at the very end, after removing all private services.
48 1
        $container->addCompilerPass(new ContainerClassMapPass($classMapBuilder), PassConfig::TYPE_AFTER_REMOVING, 0);
49 1
    }
50
}
51