Completed
Push — 3.x-dev-kit ( 4fe8f1 )
by
unknown
11:30 queued 08:33
created

AddGuesserCompilerPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 4
c 1
b 1
f 0
lcom 0
cbo 3
dl 0
loc 36
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 30 4
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[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 Sonata\DoctrineORMAdminBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
/**
19
 * @author Thomas Rabaix <[email protected]>
20
 */
21
class AddGuesserCompilerPass implements CompilerPassInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function process(ContainerBuilder $container)
27
    {
28
29
        // ListBuilder
30
        $definition = $container->getDefinition('sonata.admin.guesser.orm_list_chain');
31
        $services = array();
32
        foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_list') as $id => $attributes) {
33
            $services[] = new Reference($id);
34
        }
35
36
        $definition->replaceArgument(0, $services);
37
38
        // DatagridBuilder
39
        $definition = $container->getDefinition('sonata.admin.guesser.orm_datagrid_chain');
40
        $services = array();
41
        foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_datagrid') as $id => $attributes) {
42
            $services[] = new Reference($id);
43
        }
44
45
        $definition->replaceArgument(0, $services);
46
47
        // ShowBuilder
48
        $definition = $container->getDefinition('sonata.admin.guesser.orm_show_chain');
49
        $services = array();
50
        foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_show') as $id => $attributes) {
51
            $services[] = new Reference($id);
52
        }
53
54
        $definition->replaceArgument(0, $services);
55
    }
56
}
57