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

FixtureRegistryPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

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 FixtureRegistryPass implements CompilerPassInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function process(ContainerBuilder $container)
28
    {
29
        if (!$container->has('sylius_fixtures.fixture_registry')) {
30
            return;
31
        }
32
33
        $fixtureRegistry = $container->findDefinition('sylius_fixtures.fixture_registry');
34
35
        $taggedServices = $container->findTaggedServiceIds('sylius_fixtures.fixture');
36
        foreach (array_keys($taggedServices) as $id) {
37
            $fixtureRegistry->addMethodCall('addFixture', [new Reference($id)]);
38
        }
39
    }
40
}
41