Completed
Push — master ( ab8175...d69783 )
by Kamil
15s
created

ListenerRegistryPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 3
eloc 7
nc 3
nop 1
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