AspectCollectorPass::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
/**
3
 * Go! AOP framework
4
 *
5
 * @copyright Copyright 2015, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Go\Symfony\GoAopBundle\DependencyInjection\Compiler;
12
13
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Symfony\Component\DependencyInjection\Reference;
16
17
/**
18
 * Collects all aspects into the one single parameter
19
 */
20
class AspectCollectorPass implements CompilerPassInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function process(ContainerBuilder $container)
26
    {
27
        if (!$container->hasDefinition('goaop.aspect.container')) {
28
            return;
29
        }
30
31
        $aspectIds       = $container->findTaggedServiceIds('goaop.aspect');
32
        $aspectContainer = $container->getDefinition('goaop.aspect.container');
33
        foreach ($aspectIds as $aspectId => $aspectTags) {
34
            $aspectContainer->addMethodCall('registerAspect', array(new Reference($aspectId)));
35
        }
36
    }
37
}