QueueConfiguration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace SfCod\QueueBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
use Symfony\Component\Config\Definition\ConfigurationInterface;
8
use Symfony\Component\HttpKernel\Kernel;
9
10
/**
11
 * Class QueueConfiguration
12
 *
13
 * @author Virchenko Maksim <[email protected]>
14
 *
15
 * @package SfCod\QueueBundle\DependencyInjection
16
 */
17
class QueueConfiguration implements ConfigurationInterface
18
{
19
    /**
20
     * Generates the configuration tree builder.
21
     *
22
     * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
23
     */
24
    public function getConfigTreeBuilder()
25
    {
26
        if (Kernel::VERSION_ID >= 40300) {
27
            $treeBuilder = new TreeBuilder('sfcod_queue');
28
            $rootNode = $treeBuilder->getRootNode();
29
        } else {
30
            $treeBuilder = new TreeBuilder();
0 ignored issues
show
Bug introduced by
The call to TreeBuilder::__construct() misses a required argument $name.

This check looks for function calls that miss required arguments.

Loading history...
31
            $rootNode = $treeBuilder->root('sfcod_queue');
0 ignored issues
show
Bug introduced by
The method root() does not seem to exist on object<Symfony\Component...on\Builder\TreeBuilder>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
        }
33
34
        $this->addConnections($rootNode);
35
36
        return $treeBuilder;
37
    }
38
39
    /**
40
     * Add connections config
41
     *
42
     * @param ArrayNodeDefinition $rootNode
43
     */
44
    private function addConnections(ArrayNodeDefinition $rootNode)
45
    {
46
        $rootNode
47
            ->children()
48
                ->arrayNode('namespaces')
49
                    ->scalarPrototype()->end()
50
                ->end()
51
            ->end()
52
            ->children()
53
            ->arrayNode('drivers')
54
                ->useAttributeAsKey('name')
55
                    ->scalarPrototype()->end()
56
                ->end()
57
            ->end()
58
            ->children()
59
            ->arrayNode('connections')
60
                ->useAttributeAsKey('name')
61
                    ->arrayPrototype()
62
                        ->children()
63
                            ->scalarNode('driver')->end()
64
                            ->scalarNode('collection')->end()
65
                            ->scalarNode('connection')->end()
66
                            ->scalarNode('queue')->end()
67
                            ->scalarNode('expire')->end()
68
                            ->scalarNode('limit')->end()
69
                        ->end()
70
                    ->end()
71
                ->end()
72
            ->end();
73
    }
74
}
75