ZichtPageBundle   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 29
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 24 4
1
<?php
2
/**
3
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
namespace Zicht\Bundle\PageBundle;
7
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\HttpKernel\Bundle\Bundle;
10
use Sonata\AdminBundle\DependencyInjection\Compiler\AddDependencyCallsCompilerPass;
11
12
/**
13
 * Bundle providing "page" -> "content-item" structure
14
 */
15
class ZichtPageBundle extends Bundle
16
{
17
    /**
18
     * @{inheritDoc}
19
     */
20
    public function build(ContainerBuilder $container)
21
    {
22
        parent::build($container);
23
24
        $generatorPass = new DependencyInjection\CompilerPass\GenerateAdminServicesCompilerPass();
25
26
        // if the Sonata bundle is configured before this one, the compilerpass must be injected right before,
27
        // otherwise the generated services will not be recognized by Sonata.
28
        $idx = null;
29
        $beforeOptimizationPasses = $container->getCompilerPassConfig()->getBeforeOptimizationPasses();
30
31
        foreach ($beforeOptimizationPasses as $i => $pass) {
32
            if ($pass instanceof AddDependencyCallsCompilerPass) {
33
                $idx = $i;
34
                break;
35
            }
36
        }
37
38
        if (null !== $idx) {
39
            array_splice($beforeOptimizationPasses, $idx, 0, array($generatorPass));
40
        } else {
41
            $beforeOptimizationPasses[]= $generatorPass;
42
        }
43
        $container->getCompilerPassConfig()->setBeforeOptimizationPasses($beforeOptimizationPasses);
44
    }
45
}
46