Completed
Push — dev ( 4306de...25864c )
by Arnaud
02:52
created

DataProviderCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 22
ccs 0
cts 17
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 19 3
1
<?php
2
3
namespace LAG\AdminBundle\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class DataProviderCompilerPass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container)
12
    {
13
        if (!$container->has('lag.admin.factory')) {
14
            return;
15
        }
16
17
        $definition = $container->findDefinition('lag.admin.factory');
18
        $taggedServices = $container->findTaggedServiceIds('data_provider');
19
20
        foreach ($taggedServices as $id => $tags) {
21
            $definition->addMethodCall(
22
                'addDataProvider',
23
                [
24
                    $id,
25
                    new Reference($id),
26
                ]
27
            );
28
        }
29
    }
30
}
31