Completed
Push — master ( f5f8be...9684f5 )
by Sander
24:06 queued 10:40
created

Compiler/MediaHandlerCompilerPass.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\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
    public function process(ContainerBuilder $container)
20
    {
21
        if ($container->hasDefinition('kunstmaan_media.media_manager')) {
22
            $definition = $container->getDefinition('kunstmaan_media.media_manager');
23
24
            foreach ($container->findTaggedServiceIds('kunstmaan_media.media_handler') as $id => $attributes) {
25
                $definition->addMethodCall('addHandler', array(new Reference($id)));
26
            }
27
        }
28
29 View Code Duplication
        if ($container->hasDefinition('kunstmaan_media.icon_font_manager')) {
30
            $definition = $container->getDefinition('kunstmaan_media.icon_font_manager');
31
32
            foreach ($container->findTaggedServiceIds('kunstmaan_media.icon_font.loader') as $id => $attributes) {
33
                $definition->addMethodCall('addLoader', array(new Reference($id), $id));
34
            }
35
        }
36
37
        // Inject the tagged resolvers into our cache manager override
38 View Code Duplication
        if ($container->hasDefinition('kunstmaan_media.imagine.cache.manager')) {
0 ignored issues
show
This code seems to be duplicated across 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...
39
            $manager = $container->getDefinition('kunstmaan_media.imagine.cache.manager');
40
41
            foreach ($container->findTaggedServiceIds('liip_imagine.cache.resolver') as $id => $tag) {
42
                $manager->addMethodCall('addResolver', [$tag[0]['resolver'], new Reference($id)]);
43
            }
44
        }
45
    }
46
}
47