Completed
Push — master ( 59049f...fab486 )
by Tomasz
12:46 queued 02:08
created

Configuration::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Gendoria\CommandQueueRabbitMqDriverBundle\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
     * Master configuration key.
17
     *
18
     * @var string
19
     */
20
    private $alias;
21
22
    /**
23
     * Class constructor.
24
     *
25
     * @param string $alias
26
     */
27
    public function __construct($alias)
28
    {
29
        $this->alias = $alias;
30
    }
31
32
    /**
33
     * Get config tree builder instance.
34
     *
35
     * {@inheritdoc}
36
     *
37
     * @return TreeBuilder
38
     */
39
    public function getConfigTreeBuilder()
40
    {
41
        $treeBuilder = new TreeBuilder();
42
        $rootNode = $treeBuilder->root($this->alias);
43
        $rootNode->children()
44
            ->arrayNode('drivers')
45
                ->prototype('array')
46
                    ->children()
47
                        ->scalarNode('rabbitmq_connection')
48
                            ->cannotBeEmpty()
49
                            ->isRequired()
50
                        ->end()
51
                        ->scalarNode('exchange_name')
52
                            ->cannotBeEmpty()
53
                            ->isRequired()
54
                        ->end()
55
                        ->scalarNode('consumer_name')
56
                            ->cannotBeEmpty()
57
                            ->isRequired()
58
                        ->end()
59
                        ->scalarNode('consumer_queue_name')
60
                            ->cannotBeEmpty()
61
                            ->isRequired()
62
                        ->end()
63
                        ->scalarNode('producer_name')
64
                            ->cannotBeEmpty()
65
                            ->isRequired()
66
                        ->end()
67
                    ->end()
68
                ->end()
69
            ->end()
70
        ->end();
71
72
        // Here you should define the parameters that are allowed to
73
        // configure your bundle. See the documentation linked above for
74
        // more information on that topic.
75
76
        return $treeBuilder;
77
    }
78
}
79