Completed
Push — master ( a95d84...16d9d4 )
by Joshua
9s
created

EventSubscribersPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 4
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 9 2
1
<?php
2
3
namespace As3\Bundle\ModlrBundle\DependencyInjection\Compiler;
4
5
use As3\Bundle\ModlrBundle\DependencyInjection\Utility;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
/**
11
 * Adds event subscribers to the event dispatcher.
12
 *
13
 * @author  Jacob Bare <[email protected]>
14
 */
15
class EventSubscribersPass implements CompilerPassInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function process(ContainerBuilder $container)
21
    {
22
        $dispatcher = $container->getDefinition(Utility::getAliasedName('event_dispatcher'));
23
24
        $tagged = $container->findTaggedServiceIds(Utility::getAliasedName('event_subscriber'));
25
        foreach ($tagged as $id => $tags) {
26
            $dispatcher->addMethodCall('addSubscriber', [new Reference($id)]);
27
        }
28
    }
29
}
30