Completed
Push — master ( caead5...f1379b )
by Peter
06:59
created

NamedEventListenerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 17
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 11 3
1
<?php
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2016, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
10
namespace GpsLab\Bundle\DomainEvent\DependencyInjection\Compiler;
11
12
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
use Symfony\Component\DependencyInjection\Reference;
15
16
class NamedEventListenerPass implements CompilerPassInterface
17
{
18
    /**
19
     * @param ContainerBuilder $container
20
     */
21
    public function process(ContainerBuilder $container)
22
    {
23
        if (!$container->has('domain_event.locator.named_event')) {
24
            return;
25
        }
26
27
        $definition = $container->findDefinition('domain_event.locator.named_event');
28
        foreach ($container->findTaggedServiceIds('domain_event.named_event_listener') as  $id => $attributes) {
29
            $definition->addMethodCall('register', [new Reference($id), $attributes[0]['event']]);
30
        }
31
    }
32
}
33