Configuration::getConfigTreeBuilder()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 21
nc 1
nop 0
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\Config\Definition\Builder\TreeBuilder;
14
use Symfony\Component\Config\Definition\ConfigurationInterface;
15
16
/**
17
 * This is the class that validates and merges configuration from your app/config files
18
 *
19
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
20
 */
21
class Configuration implements ConfigurationInterface
22
{
23
    /**
24
     * {@inheritDoc}
25
     */
26
    public function getConfigTreeBuilder()
27
    {
28
        $treeBuilder = new TreeBuilder();
29
        $rootNode    = $treeBuilder->root('af_dont_translate');
30
31
        $rootNode
32
            ->children()
33
                ->scalarNode('mode')
34
                    ->info('The mode that activates the don\'t translate mode')
35
                    ->defaultValue('get')
36
                ->end()
37
                ->scalarNode('param_name')
38
                    ->info('The parameter name activating the don\'t translate mode')
39
                    ->defaultValue('untranslate')
40
                ->end()
41
                ->arrayNode('roles')
42
                    ->info('Authorized roles list')
43
                    ->example('ROLE_TRANSLATOR or [ROLE_TRANSLATOR, ROLE_ADMIN]')
44
                    ->prototype('scalar')
45
                    ->end()
46
                ->end()
47
            ->end()
48
        ;
49
50
        return $treeBuilder;
51
    }
52
}
53