AfDontTranslateExtension::load()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the AfDontTranslateBundle package
5
 *
6
 * (c) Antoine Froger <[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
namespace Af\Bundle\DontTranslateBundle\DependencyInjection;
12
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
16
use Symfony\Component\DependencyInjection\Loader;
17
18
/**
19
 * This is the class that loads and manages your bundle configuration
20
 *
21
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
22
 */
23
class AfDontTranslateExtension extends Extension
24
{
25
    /**
26
     * {@inheritDoc}
27
     */
28
    public function load(array $configs, ContainerBuilder $container)
29
    {
30
        $configuration = new Configuration();
31
        $config        = $this->processConfiguration($configuration, $configs);
32
33
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
34
        $loader->load('services.xml');
35
36
        $definition = $container->getDefinition('af_dont_translate.debug.request_listener');
37
        $definition->replaceArgument(3, $config['mode']);
38
        $definition->replaceArgument(4, $config['param_name']);
39
        $definition->replaceArgument(5, isset($config['roles']) ? $config['roles'] : array());
40
    }
41
}
42