Completed
Pull Request — master (#90)
by Arnaud
19:08
created

DataProviderCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 27
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 19 3
1
<?php
2
3
namespace LAG\AdminBundle\DependencyInjection\CompilerPass;
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
    /**
12
     * Add the tagged data provider to the DataProviderFactory.
13
     *
14
     * @param ContainerBuilder $container
15
     */
16
    public function process(ContainerBuilder $container)
17
    {
18
        if (!$container->has('lag.admin.data_providers_factory')) {
19
            return;
20
        }
21
22
        $definition = $container->findDefinition('lag.admin.data_providers_factory');
23
        $taggedServices = $container->findTaggedServiceIds('data_provider');
24
25
        foreach ($taggedServices as $id => $tags) {
26
            $definition->addMethodCall(
27
                'addDataProvider',
28
                [
29
                    $id,
30
                    new Reference($id),
31
                ]
32
            );
33
        }
34
    }
35
}
36