Completed
Push — master ( caead5...f1379b )
by Peter
06:59
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 0
cts 27
cp 0
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 24
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2016, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
namespace GpsLab\Bundle\DomainEvent\DependencyInjection;
10
11
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
12
use Symfony\Component\Config\Definition\ConfigurationInterface;
13
14
class Configuration implements ConfigurationInterface
15
{
16
    /**
17
     * Config tree builder.
18
     *
19
     * Example config:
20
     *
21
     * gpslab_domain_event:
22
     *     locator: 'named_event'
23
     *     name_resolver: 'event_class'
24
     *     doctrine:
25
     *         handle_events:
26
     *             - 'prePersist'
27
     *             - 'preUpdate'
28
     *             - 'preRemove'
29
     *             - 'preFlush'
30
     *         connections:
31
     *             - 'default'
32
     *
33
     * @return TreeBuilder
34
     */
35
    public function getConfigTreeBuilder()
36
    {
37
        return (new TreeBuilder())
38
            ->root('gpslab_domain_event')
39
                ->children()
40
                    ->scalarNode('locator')
41
                        ->cannotBeEmpty()
42
                        ->defaultValue('named_event')
43
                    ->end()
44
                    ->scalarNode('name_resolver')
45
                        ->cannotBeEmpty()
46
                        ->defaultValue('event_class')
47
                    ->end()
48
                    ->arrayNode('doctrine')
49
                        ->children()
50
                            ->arrayNode('handle_events')
51
                                ->prototype('scalar')
52
                            ->end()
53
                            ->arrayNode('connections')
54
                                ->prototype('scalar')
55
                            ->end()
56
                        ->end()
57
                    ->end()
58
                ->end()
59
            ->end()
60
        ;
61
    }
62
}
63