Completed
Push — master ( 4c7b9c...e919dc )
by Kamil
21:11
created

ListenerRegistryPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 19
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 3
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Bundle\FixturesBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
use Webmozart\Assert\Assert;
18
19
/**
20
 * @author Kamil Kokot <[email protected]>
21
 */
22
final class ListenerRegistryPass implements CompilerPassInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function process(ContainerBuilder $container)
28
    {
29
        if (!$container->has('sylius_fixtures.listener_registry')) {
30
            return;
31
        }
32
33
        $listenerRegistry = $container->findDefinition('sylius_fixtures.listener_registry');
34
35
        $taggedServices = $container->findTaggedServiceIds('sylius_fixtures.listener');
36
        foreach (array_keys($taggedServices) as $id) {
37
            $listenerRegistry->addMethodCall('addListener', [new Reference($id)]);
38
        }
39
    }
40
}
41