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\MediaBundle\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 | * MediaHandlerCompilerPass |
||
11 | */ |
||
12 | class MediaHandlerCompilerPass implements CompilerPassInterface |
||
13 | { |
||
14 | /** |
||
15 | * You can modify the container here before it is dumped to PHP code. |
||
16 | * |
||
17 | * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container |
||
18 | */ |
||
19 | 3 | public function process(ContainerBuilder $container) |
|
20 | { |
||
21 | 3 | if ($container->hasDefinition('kunstmaan_media.media_manager')) { |
|
22 | 1 | $definition = $container->getDefinition('kunstmaan_media.media_manager'); |
|
23 | |||
24 | 1 | foreach ($container->findTaggedServiceIds('kunstmaan_media.media_handler') as $id => $attributes) { |
|
25 | 1 | $definition->addMethodCall('addHandler', array(new Reference($id))); |
|
26 | } |
||
27 | } |
||
28 | |||
29 | 3 | View Code Duplication | if ($container->hasDefinition('kunstmaan_media.icon_font_manager')) { |
0 ignored issues
–
show
|
|||
30 | 1 | $definition = $container->getDefinition('kunstmaan_media.icon_font_manager'); |
|
31 | |||
32 | 1 | foreach ($container->findTaggedServiceIds('kunstmaan_media.icon_font.loader') as $id => $attributes) { |
|
33 | 1 | $definition->addMethodCall('addLoader', array(new Reference($id), $id)); |
|
34 | } |
||
35 | } |
||
36 | |||
37 | // Inject the tagged resolvers into our cache manager override |
||
38 | 3 | View Code Duplication | if ($container->hasDefinition('Kunstmaan\MediaBundle\Helper\Imagine\CacheManager')) { |
39 | 1 | $manager = $container->getDefinition('Kunstmaan\MediaBundle\Helper\Imagine\CacheManager'); |
|
40 | |||
41 | 1 | foreach ($container->findTaggedServiceIds('liip_imagine.cache.resolver') as $id => $tag) { |
|
42 | 1 | $manager->addMethodCall('addResolver', [$tag[0]['resolver'], new Reference($id)]); |
|
43 | } |
||
44 | } |
||
45 | 3 | } |
|
46 | } |
||
47 |
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.