Code Duplication    Length = 18-27 lines in 2 locations

src/LAG/AdminBundle/DependencyInjection/CompilerPass/DataProviderCompilerPass.php 1 location

@@ 9-35 (lines=27) @@
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

src/LAG/AdminBundle/DependencyInjection/CompilerPass/ResponderCompilerPass.php 1 location

@@ 9-26 (lines=18) @@
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class ResponderCompilerPass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container)
12
    {
13
        if (!$container->has('lag.admin.responder.storage')) {
14
            return;
15
        }
16
        $storage = $container->getDefinition('lag.admin.responder.storage');
17
        $responderIds = $container->findTaggedServiceIds('responder');
18
    
19
        foreach ($responderIds as $responderId) {
20
            $storage->addMethodCall('add', [
21
                $responderId,
22
                new Reference($responderId),
23
            ]);
24
        }
25
    }
26
}
27