AddGuesserCompilerPass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 32
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 29 4
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