Completed
Push — master ( 0a7932...aee286 )
by Maksim
13s
created

PostProcessorsCompilerPass::process()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 12
Ratio 100 %
Metric Value
dl 12
loc 12
rs 9.2
cc 4
eloc 6
nc 3
nop 1
1
<?php
2
3
namespace Liip\ImagineBundle\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
 * Compiler pass to register post_processors tagged with liip_imagine.filter.post_processor.
11
 *
12
 * @author Konstantin Tjuterev <[email protected]>
13
 */
14 View Code Duplication
class PostProcessorsCompilerPass implements CompilerPassInterface
0 ignored issues
show
Duplication introduced by
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...
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function process(ContainerBuilder $container)
20
    {
21
        $tags = $container->findTaggedServiceIds('liip_imagine.filter.post_processor');
22
23
        if (count($tags) > 0 && $container->hasDefinition('liip_imagine.filter.manager')) {
24
            $manager = $container->getDefinition('liip_imagine.filter.manager');
25
26
            foreach ($tags as $id => $tag) {
27
                $manager->addMethodCall('addPostProcessor', array($tag[0]['post_processor'], new Reference($id)));
28
            }
29
        }
30
    }
31
}
32