Configuration::addConsoleSection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 9
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Social Live project.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace AMF\ConsoleBundle\DependencyInjection;
11
12
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
13
use Symfony\Component\Config\Definition\ConfigurationInterface;
14
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
15
16
/**
17
 * Class Configuration.
18
 *
19
 * @author Amine Fattouch <[email protected]>
20
 */
21
class Configuration implements ConfigurationInterface
22
{
23
    /**
24
     * Generates the configuration tree builder.
25
     *
26
     * @return TreeBuilder The tree builder
27
     */
28
    public function getConfigTreeBuilder()
29
    {
30
        $treeBuilder = new TreeBuilder();
31
32
        $rootNode = $treeBuilder->root('amf_console');
33
        $this->addConsoleSection($rootNode);
34
35
        return $treeBuilder;
36
    }
37
38
    /**
39
     * Adds the config of prefixes to global config.
40
     *
41
     * @param ArrayNodeDefinition $node The root element for the config nodes.
42
     *
43
     * @return void
44
     */
45
    protected function addConsoleSection(ArrayNodeDefinition $node)
46
    {
47
        $node->fixXmlConfig('allowed_prefix')
48
            ->children()
49
                ->arrayNode('allowed_prefixes')
50
                    ->isRequired()
51
                    ->cannotBeEmpty()
52
                    ->prototype('scalar')->end()
53
                ->end()
54
            ->end();
55
    }
56
}
57