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

AddGuesserCompilerPass::process()   B

Complexity

Conditions 4
Paths 8

Size

Total Lines 30
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 30
rs 8.5806
cc 4
eloc 16
nc 8
nop 1
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