Completed
Push — master ( 6b5246...8691e9 )
by David
04:53 queued 02:40
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 30
rs 8.8571
cc 1
eloc 25
nc 1
nop 0
1
<?php
2
3
namespace A2lix\AutoFormBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
/**
9
 * @author David ALLIX
10
 * @author Gonzalo Vilaseca <[email protected]>
11
 */
12
class Configuration implements ConfigurationInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function getConfigTreeBuilder()
18
    {
19
        $treeBuilder = new TreeBuilder();
20
        $rootNode = $treeBuilder->root('a2lix_auto_form');
21
22
        $rootNode
23
            ->children()
24
                ->scalarNode('locale_provider')->defaultValue('default')->end()
25
                ->scalarNode('default_locale')->defaultNull()->end()
26
                ->arrayNode('locales')
27
                    ->beforeNormalization()
28
                        ->ifString()
29
                        ->then(function ($v) { return preg_split('/\s*,\s*/', $v); })
30
                    ->end()
31
                    ->requiresAtLeastOneElement()
32
                    ->prototype('scalar')->end()
33
                ->end()
34
                ->arrayNode('required_locales')
35
                    ->beforeNormalization()
36
                        ->ifString()
37
                        ->then(function ($v) { return preg_split('/\s*,\s*/', $v); })
38
                    ->end()
39
                    ->prototype('scalar')->end()
40
                ->end()
41
                ->scalarNode('templating')->defaultValue('A2lixAutoFormBundle::default.html.twig')->end()
42
            ->end()
43
        ;
44
45
        return $treeBuilder;
46
    }
47
}
48