Completed
Push — master ( 531aca...edc713 )
by Kamil
04:19
created

ContextRegistryPass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of the ContextServiceExtension package.
5
 *
6
 * (c) FriendsOfBehat
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 FriendsOfBehat\ContextServiceExtension\ServiceContainer\Scenario;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Definition;
17
18
/**
19
 * @internal
20
 */
21
final class ContextRegistryPass implements CompilerPassInterface
22
{
23
    /**
24
     * @var Definition
25
     */
26
    private $contextRegistryDefinition;
27
28
    /**
29
     * @param Definition $contextRegistryDefinition
30
     */
31
    public function __construct(Definition $contextRegistryDefinition)
32
    {
33
        $this->contextRegistryDefinition = $contextRegistryDefinition;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function process(ContainerBuilder $container)
40
    {
41
        $taggedServices = $container->findTaggedServiceIds('fob.context_service');
42
43
        foreach ($taggedServices as $id => $tags) {
44
            $this->contextRegistryDefinition->addMethodCall(
45
                'add',
46
                [$id, $container->findDefinition($id)->getClass()]
47
            );
48
        }
49
    }
50
}
51