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

MediaHandlerCompilerPass::process()   B

Complexity

Conditions 7
Paths 12

Size

Total Lines 27

Duplication

Lines 14
Ratio 51.85 %

Importance

Changes 0
Metric Value
dl 14
loc 27
rs 8.5546
c 0
b 0
f 0
cc 7
nc 12
nop 1
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')) {
0 ignored issues
show
Duplication introduced by
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...
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
Duplication introduced by
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