Configuration.php 4.19 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php

/*
 * © 2016 IRSTEA
 * Guillaume Perréal <guillaume.perreal@irstea.fr>
 * Tous droits réservés.
 */

namespace Irstea\PlantUmlBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
 * Description of Configuration
 *
 * @author Guillaume Perréal <guillaume.perreal@irstea.fr>
 */
class Configuration implements ConfigurationInterface
{
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();

        $treeBuilder->root('irstea_plant_uml')
            ->children()
                ->arrayNode('binaries')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->scalarNode('java')
                            ->defaultValue("java")
                        ->end()
                        ->scalarNode('plamtuml_jar')
                            ->defaultValue("plantuml.jar")
                        ->end()
                        ->scalarNode('dot')
                            ->defaultValue("dot")
                        ->end()
                    ->end()
                ->end()
                ->append($this->buildGraphNode())
            ->end();

        return $treeBuilder;
    }

    protected function buildGraphNode()
    {
        $node = (new TreeBuilder())->root('graphs');

        $node
            ->useAttributeAsKey('name')
            ->prototype('array')
                ->children()
                    ->arrayNode('sources')
                        ->addDefaultsIfNotSet()
                        ->children()
                            ->enumNode('type')
                                ->defaultValue('classes')
                                ->values(['classes', 'entities'])
                            ->end()
                            ->scalarNode('entity_manager')
                                ->defaultValue('default')
                            ->end()
                            ->arrayNode('directories')
                                ->defaultValue(['%kernel.root_dir%/../src'])
                                ->prototype('scalar')->end()
                            ->end()
                            ->append($this->buildFilterNode('include'))
                            ->append($this->buildFilterNode('exclude'))
                        ->end()
                    ->end()
                    ->arrayNode('layout')
                        ->addDefaultsIfNotSet()
                        ->children()
                            ->enumNode('namespaces')
                                ->defaultValue('php')
                                ->values(['bundles', 'php', 'flat', 'entities'])
                            ->end()
                            ->append($this->buildFilterNode('include'))
                            ->append($this->buildFilterNode('exclude'))
                         ->end()
                    ->end()
                    ->arrayNode('decoration')
                        ->addDefaultsIfNotSet()
                        ->children()
                            ->arrayNode('decorators')
88
                                ->defaultValue(['inheritance', 'traits', 'interfaces', 'entity', 'associations', 'properties', 'methods'])
89
                                ->prototype('enum')
90
                                    ->values(['inheritance', 'traits', 'interfaces', 'entity', 'associations', 'properties', 'methods'])
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
                                ->end()
                            ->end()
                            ->append($this->buildFilterNode('include'))
                            ->append($this->buildFilterNode('exclude'))
                        ->end()
                    ->end()
                ->end()
            ->end();

        return $node;
    }

    protected function buildFilterNode($nodeName)
    {
        $node = (new TreeBuilder())->root($nodeName);

        $node
            ->children()
                ->arrayNode('directories')
                    ->prototype('scalar')->end()
                ->end()
                ->arrayNode('namespaces')
                    ->prototype('scalar')->end()
                ->end()
            ->end();

        return $node;
    }

}