Completed
Push — master ( 3cdfc2...4aa078 )
by Maksim
03:09
created

ConfigSourcePass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.0175

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 7
cts 8
cp 0.875
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1
crap 3.0175
1
<?php
2
3
/*
4
 * This file is part of the FOSElasticaBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
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
/**
13
 * This file is part of the FOSElasticaBundle project.
14
 *
15
 * (c) Tim Nagel <[email protected]>
16
 *
17
 * For the full copyright and license information, please view the LICENSE
18
 * file that was distributed with this source code.
19
 */
20
21
namespace FOS\ElasticaBundle\DependencyInjection\Compiler;
22
23
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
24
use Symfony\Component\DependencyInjection\ContainerBuilder;
25
use Symfony\Component\DependencyInjection\Reference;
26
27
class ConfigSourcePass implements CompilerPassInterface
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32 3
    public function process(ContainerBuilder $container)
33
    {
34 3
        if (!$container->hasDefinition('fos_elastica.config_manager')) {
35
            return;
36
        }
37
38 3
        $sources = [];
39 3
        foreach (array_keys($container->findTaggedServiceIds('fos_elastica.config_source')) as $id) {
40 3
            $sources[] = new Reference($id);
41
        }
42
43 3
        $container->getDefinition('fos_elastica.config_manager')->replaceArgument(0, $sources);
44 3
    }
45
}
46