AddResourcePass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 27
rs 10
c 0
b 0
f 0
ccs 17
cts 17
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 21 4
1
<?php
2
3
/*
4
 * This file is part of the AsmTranslationLoaderBundle package.
5
 *
6
 * (c) Marc Aschmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Asm\TranslationLoaderBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
/**
19
 * Compiler pass that adds additional resources to the Translator.
20
 *
21
 * @author Christian Flothmann <[email protected]>
22
 */
23
class AddResourcePass implements CompilerPassInterface
24
{
25
    /**
26
     * {@inheritDoc}
27
     */
28 8
    public function process(ContainerBuilder $container)
29
    {
30 8
        $resources = $container->getParameter('asm_translation_loader.resources');
31 8
        $translator = $container->findDefinition('translator.default');
32
33 8
        if (null !== $translator) {
34 6
            foreach ($resources as $locale => $domains) {
35 4
                foreach ($domains as $domain) {
36 4
                    $translator->addMethodCall(
37 4
                        'addResource',
38
                        array(
39 4
                            'db',
40 4
                            new Reference('asm_translation_loader.translation_manager_resource'),
41 4
                            $locale,
42 4
                            $domain,
43
                        )
44 4
                    );
45 4
                }
46 6
            }
47 6
        }
48 8
    }
49
}
50