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\AdminBundle\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 | * This compiler pass makes it possible to adapt the menu |
||
11 | */ |
||
12 | View Code Duplication | class MenuCompilerPass implements CompilerPassInterface |
|
0 ignored issues
–
show
|
|||
13 | { |
||
14 | /** |
||
15 | * @param ContainerBuilder $container |
||
16 | */ |
||
17 | public function process(ContainerBuilder $container) |
||
18 | { |
||
19 | if (!$container->hasDefinition('kunstmaan_admin.menubuilder')) { |
||
20 | return; |
||
21 | } |
||
22 | |||
23 | $definition = $container->getDefinition('kunstmaan_admin.menubuilder'); |
||
24 | |||
25 | foreach ($container->findTaggedServiceIds('kunstmaan_admin.menu.adaptor') as $id => $attributes) { |
||
26 | $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; |
||
27 | |||
28 | $definition->addMethodCall('addAdaptMenu', array(new Reference($id), $priority)); |
||
29 | } |
||
30 | } |
||
31 | } |
||
32 |
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.