Completed
Push — master ( 91fdab...75a7b9 )
by
unknown
13:37
created

Compiler/SearchConfigurationCompilerPass.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\SearchBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
/**
10
 * CompilerPass class for SearchConfiguration
11
 *
12
 * Will find all services tagged "kunstmaan_search.search_configuration" and will add them to the chain with their
13
 * alias.
14
 */
15 View Code Duplication
class SearchConfigurationCompilerPass implements CompilerPassInterface
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    /**
18
     * @param ContainerBuilder $container
19
     */
20
    public function process(ContainerBuilder $container)
21
    {
22
        if (!$container->hasDefinition('kunstmaan_search.search_configuration_chain')) {
23
            return;
24
        }
25
26
        $definition = $container->getDefinition('kunstmaan_search.search_configuration_chain');
27
        $taggedServices = $container->findTaggedServiceIds('kunstmaan_search.search_configuration');
28
29
        foreach ($taggedServices as $id => $tagAttributes) {
30
            foreach ($tagAttributes as $attributes) {
31
                $definition->addMethodCall(
32
                    'addConfiguration',
33
                    array(new Reference($id), $attributes['alias'])
34
                );
35
            }
36
        }
37
    }
38
}
39