Completed
Push — master ( eec44f...f37f32 )
by Julien
05:06 queued 01:29
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 48
Code Lines 45

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 4
Bugs 0 Features 2
Metric Value
c 4
b 0
f 2
dl 0
loc 48
ccs 0
cts 47
cp 0
rs 9.125
cc 1
eloc 45
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Itkg\DelayEventBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
/**
9
 * This is the class that validates and merges configuration from your app/config files
10
 *
11
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
12
 */
13
class Configuration implements ConfigurationInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function getConfigTreeBuilder()
19
    {
20
        $treeBuilder = new TreeBuilder();
21
        $rootNode = $treeBuilder->root('itkg_delay_event');
22
        $rootNode
23
            ->fixXmlConfig('channel')
24
            ->children()
25
                ->arrayNode('processor')
26
                    ->children()
27
                        ->arrayNode('retry_count')
28
                            ->children()
29
                                ->scalarNode('normal')->defaultValue(1)->end()
30
                                ->scalarNode('critic')->defaultValue(1)->end()
31
                            ->end()
32
                        ->end()
33
                    ->end()
34
                ->end()
35
                ->arrayNode('events')
36
                    ->prototype('array')
37
                        ->children()
38
                            ->enumNode('type')
39
                                ->values(['normal', 'critic'])
40
                                ->defaultValue('normal')
41
                            ->end()
42
                        ->end()
43
                    ->end()
44
                ->end()
45
                ->arrayNode('channels')
46
                    ->addDefaultChildrenIfNoneSet('default')
47
                    ->useAttributeAsKey('name')
48
                    ->prototype('array')
49
                    ->children()
50
                        ->integerNode('events_limit_per_run')
51
                            ->defaultNull()
52
                            ->min(0)
53
                        ->end()
54
                        ->arrayNode('include')
55
                            ->prototype('scalar')->end()
56
                        ->end()
57
                        ->arrayNode('exclude')
58
                            ->prototype('scalar')->end()
59
                        ->end()
60
                    ->end()
61
                ->end()
62
            ->end();
63
64
        return $treeBuilder;
65
    }
66
}
67