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

IndexPass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4.0218

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 8
cts 9
cp 0.8889
rs 9.2
c 0
b 0
f 0
cc 4
eloc 8
nc 4
nop 1
crap 4.0218
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 IndexPass implements CompilerPassInterface
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32 3
    public function process(ContainerBuilder $container)
33
    {
34 3
        if (!$container->hasDefinition('fos_elastica.index_manager')) {
35
            return;
36
        }
37
38 3
        $indexes = [];
39 3
        foreach ($container->findTaggedServiceIds('fos_elastica.index') as $id => $tags) {
40 3
            foreach ($tags as $tag) {
41 3
                $indexes[$tag['name']] = new Reference($id);
42
            }
43
        }
44
45 3
        $container->getDefinition('fos_elastica.index_manager')->replaceArgument(0, $indexes);
46 3
    }
47
}
48