Completed
Pull Request — master (#917)
by Dmitry
08:52
created

IndexPass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20
Metric Value
dl 0
loc 15
ccs 0
cts 9
cp 0
rs 9.2
cc 4
eloc 8
nc 4
nop 1
crap 20
1
<?php
2
3
/**
4
 * This file is part of the FOSElasticaBundle project.
5
 *
6
 * (c) Tim Nagel <[email protected]>
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 FOS\ElasticaBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
class IndexPass implements CompilerPassInterface
19
{
20
    /**
21
     * {@inheritDoc}
22
     */
23
    public function process(ContainerBuilder $container)
24
    {
25
        if (!$container->hasDefinition('fos_elastica.index_manager')) {
26
            return;
27
        }
28
29
        $indexes = array();
30
        foreach ($container->findTaggedServiceIds('fos_elastica.index') as $id => $tags) {
31
            foreach ($tags as $tag) {
32
                $indexes[$tag['name']] = new Reference($id);
33
            }
34
        }
35
36
        $container->getDefinition('fos_elastica.index_manager')->replaceArgument(0, $indexes);
37
    }
38
}
39