Completed
Pull Request — master (#1331)
by Maksim
06:58 queued 54s
created

IndexPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 21
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 4
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
    public function process(ContainerBuilder $container)
33
    {
34
        if (!$container->hasDefinition('fos_elastica.index_manager')) {
35
            return;
36
        }
37
38
        $indexes = [];
39
        foreach ($container->findTaggedServiceIds('fos_elastica.index') as $id => $tags) {
40
            foreach ($tags as $tag) {
41
                $indexes[$tag['name']] = new Reference($id);
42
            }
43
        }
44
45
        $container->getDefinition('fos_elastica.index_manager')->replaceArgument(0, $indexes);
46
    }
47
}
48