Completed
Push — 2.x ( 359f6e )
by Sullivan
16:25 queued 14:10
created

AddGuesserCompilerPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3
Metric Value
wmc 4
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.
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\Definition;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
/*
20
 *
21
 * @author Thomas Rabaix <[email protected]>
22
 */
23
class AddGuesserCompilerPass implements CompilerPassInterface
24
{
25
    /**
26
     * {@inheritDoc}
27
     */
28
    public function process(ContainerBuilder $container)
29
    {
30
31
        // ListBuilder
32
        $definition = $container->getDefinition('sonata.admin.guesser.orm_list_chain');
33
        $services   = array();
34
        foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_list') as $id => $attributes) {
35
            $services[] = new Reference($id);
36
        }
37
38
        $definition->replaceArgument(0, $services);
39
40
        // DatagridBuilder
41
        $definition = $container->getDefinition('sonata.admin.guesser.orm_datagrid_chain');
42
        $services   = array();
43
        foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_datagrid') as $id => $attributes) {
44
            $services[] = new Reference($id);
45
        }
46
47
        $definition->replaceArgument(0, $services);
48
49
        // ShowBuilder
50
        $definition = $container->getDefinition('sonata.admin.guesser.orm_show_chain');
51
        $services   = array();
52
        foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_show') as $id => $attributes) {
53
            $services[] = new Reference($id);
54
        }
55
56
        $definition->replaceArgument(0, $services);
57
    }
58
}
59