AddGuesserCompilerPass::process()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 9.456
c 0
b 0
f 0
cc 4
nc 8
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\DoctrineORMAdminBundle\DependencyInjection\Compiler;
15
16
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Reference;
19
20
/**
21
 * @author Thomas Rabaix <[email protected]>
22
 */
23
class AddGuesserCompilerPass implements CompilerPassInterface
24
{
25
    public function process(ContainerBuilder $container): void
26
    {
27
        // ListBuilder
28
        $definition = $container->getDefinition('sonata.admin.guesser.orm_list_chain');
29
        $services = [];
30
        foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_list') as $id => $attributes) {
31
            $services[] = new Reference($id);
32
        }
33
34
        $definition->replaceArgument(0, $services);
35
36
        // DatagridBuilder
37
        $definition = $container->getDefinition('sonata.admin.guesser.orm_datagrid_chain');
38
        $services = [];
39
        foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_datagrid') as $id => $attributes) {
40
            $services[] = new Reference($id);
41
        }
42
43
        $definition->replaceArgument(0, $services);
44
45
        // ShowBuilder
46
        $definition = $container->getDefinition('sonata.admin.guesser.orm_show_chain');
47
        $services = [];
48
        foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_show') as $id => $attributes) {
49
            $services[] = new Reference($id);
50
        }
51
52
        $definition->replaceArgument(0, $services);
53
    }
54
}
55