Passed
Push — master ( bea9fb...617266 )
by Siim
11:02
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 31
nc 1
nop 0
dl 0
loc 36
rs 9.424
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: siim
5
 * Date: 26.02.19
6
 * Time: 10:01
7
 */
8
9
namespace Sf4\Api\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
    const NAME = 'sf4_api';
18
    const SITES = 'sites';
19
    const SITES_SITE = 'site';
20
    const SITES_URL = 'url';
21
    const SITES_TOKEN = 'token';
22
    const ROUTES = 'routes';
23
    const ROUTES_ROUTE = 'route';
24
    const ROUTES_REQUEST_CLASS = 'request_class';
25
    const ENTITIES = 'entities';
26
    const ENTITIES_TABLE_NAME = 'table_name';
27
    const ENTITIES_ENTITY_CLASS = 'entity_class';
28
29
    public function getConfigTreeBuilder()
30
    {
31
        $treeBuilder = new TreeBuilder();
32
        $rootNode = $treeBuilder->root(static::NAME);
33
34
        $rootNode
35
            ->children()
36
                ->arrayNode(static::SITES)
37
                    ->arrayPrototype()
38
                        ->children()
39
                            ->scalarNode(static::SITES_SITE)->end()
40
                            ->scalarNode(static::SITES_URL)->end()
41
                            ->scalarNode(static::SITES_TOKEN)->end()
42
                        ->end()
43
                    ->end()
44
                ->end()
45
                ->arrayNode(static::ROUTES)
46
                    ->arrayPrototype()
47
                        ->children()
48
                            ->scalarNode(static::ROUTES_ROUTE)->end()
49
                            ->scalarNode(static::ROUTES_REQUEST_CLASS)->end()
50
                        ->end()
51
                    ->end()
52
                ->end()
53
                ->arrayNode(static::ENTITIES)
54
                    ->arrayPrototype()
55
                        ->children()
56
                        ->scalarNode(static::ENTITIES_TABLE_NAME)->end()
57
                        ->scalarNode(static::ENTITIES_ENTITY_CLASS)->end()
58
                        ->end()
59
                    ->end()
60
                ->end()
61
            ->end()
62
        ;
63
64
        return $treeBuilder;
65
    }
66
}
67