ResolverCompilerPass::process()   B
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 23
Code Lines 12

Duplication

Lines 23
Ratio 100 %

Importance

Changes 0
Metric Value
dl 23
loc 23
rs 8.7972
c 0
b 0
f 0
cc 4
eloc 12
nc 4
nop 1
1
<?php
2
3
/**
4
 * Copyright 2014 Jonathan Bouzekri. All rights reserved.
5
 *
6
 * @copyright Copyright 2014 Jonathan Bouzekri <[email protected]>
7
 * @license https://github.com/jbouzekri/FileUploaderBundle/blob/master/LICENSE
8
 * @link https://github.com/jbouzekri/FileUploaderBundle
9
 */
10
11
namespace Jb\Bundle\FileUploaderBundle\DependencyInjection\Compiler;
12
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\Reference;
16
17
/**
18
 * ResolverCompilerPass
19
 *
20
 * @author jobou
21
 */
22 View Code Duplication
class ResolverCompilerPass implements CompilerPassInterface
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27
    public function process(ContainerBuilder $container)
28
    {
29
        if (!$container->hasDefinition('jb_fileuploader.resolver_chain')) {
30
            return;
31
        }
32
33
        $definition = $container->getDefinition(
34
            'jb_fileuploader.resolver_chain'
35
        );
36
37
        $taggedServices = $container->findTaggedServiceIds(
38
            'jb_fileuploader.resolver'
39
        );
40
41
        foreach ($taggedServices as $id => $tags) {
42
            foreach ($tags as $attributes) {
43
                $definition->addMethodCall(
44
                    'addResolver',
45
                    array(new Reference($id), $attributes["alias"])
46
                );
47
            }
48
        }
49
    }
50
}
51