1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Finite\Bundle\FiniteBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeBuilder; |
6
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
7
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* This is the class that validates and merges configuration from your app/config files. |
11
|
|
|
* |
12
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} |
13
|
|
|
*/ |
14
|
|
|
class Configuration implements ConfigurationInterface |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* {@inheritdoc} |
18
|
|
|
*/ |
19
|
5 |
|
public function getConfigTreeBuilder() |
20
|
|
|
{ |
21
|
5 |
|
$treeBuilder = new TreeBuilder('finite_finite'); |
22
|
5 |
|
if (method_exists($treeBuilder, 'root')) { |
23
|
5 |
|
$rootNode = $treeBuilder->root('finite_finite'); |
24
|
3 |
|
} else { |
25
|
|
|
$rootNode = $treeBuilder->getRootNode(); |
26
|
|
|
} |
27
|
5 |
|
$rootProto = $rootNode->useAttributeAsKey('name')->prototype('array')->children(); |
|
|
|
|
28
|
|
|
|
29
|
|
|
$rootProto |
30
|
5 |
|
->scalarNode('class')->isRequired()->end() |
31
|
5 |
|
->scalarNode('graph')->defaultValue('default')->end() |
32
|
5 |
|
->scalarNode('property_path')->defaultValue('finiteState')->end(); |
33
|
|
|
|
34
|
5 |
|
$this->addStateSection($rootProto); |
35
|
5 |
|
$this->addTransitionSection($rootProto); |
36
|
5 |
|
$this->addCallbackSection($rootProto); |
37
|
5 |
|
$rootProto->end()->end(); |
38
|
|
|
|
39
|
5 |
|
return $treeBuilder; |
40
|
2 |
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param NodeBuilder $rootProto |
44
|
|
|
*/ |
45
|
5 |
|
protected function addStateSection(NodeBuilder $rootProto) |
46
|
|
|
{ |
47
|
|
|
$rootProto |
48
|
5 |
|
->arrayNode('states') |
49
|
5 |
|
->useAttributeAsKey('name') |
50
|
5 |
|
->prototype('array') |
51
|
5 |
|
->children() |
52
|
5 |
|
->scalarNode('type')->defaultValue('normal')->end() |
53
|
5 |
|
->arrayNode('properties') |
54
|
5 |
|
->useAttributeAsKey('name') |
55
|
5 |
|
->defaultValue(array()) |
56
|
5 |
|
->prototype('variable')->end() |
57
|
5 |
|
->end() |
58
|
5 |
|
->end() |
59
|
5 |
|
->end() |
60
|
5 |
|
->end(); |
61
|
5 |
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param NodeBuilder $rootProto |
65
|
|
|
*/ |
66
|
5 |
|
protected function addTransitionSection(NodeBuilder $rootProto) |
67
|
|
|
{ |
68
|
|
|
$rootProto |
69
|
5 |
|
->arrayNode('transitions') |
70
|
5 |
|
->useAttributeAsKey('name') |
71
|
5 |
|
->prototype('array') |
72
|
5 |
|
->children() |
73
|
5 |
|
->arrayNode('from') |
74
|
5 |
|
->prototype('variable')->end() |
75
|
5 |
|
->end() |
76
|
5 |
|
->scalarNode('to')->end() |
77
|
5 |
|
->arrayNode('properties') |
78
|
5 |
|
->useAttributeAsKey('name') |
79
|
5 |
|
->defaultValue(array()) |
80
|
5 |
|
->prototype('variable')->end() |
81
|
5 |
|
->end() |
82
|
5 |
|
->end() |
83
|
5 |
|
->end() |
84
|
5 |
|
->end(); |
85
|
5 |
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param NodeBuilder $rootProto |
89
|
|
|
*/ |
90
|
5 |
|
protected function addCallbackSection(NodeBuilder $rootProto) |
91
|
|
|
{ |
92
|
5 |
|
$callbacks = $rootProto->arrayNode('callbacks')->children(); |
93
|
5 |
|
$this->addSubCallbackSection($callbacks, 'before'); |
94
|
5 |
|
$this->addSubCallbackSection($callbacks, 'after'); |
95
|
5 |
|
$callbacks->end()->end(); |
96
|
5 |
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param NodeBuilder $callbacks |
100
|
|
|
* @param string $type |
101
|
|
|
*/ |
102
|
5 |
|
private function addSubCallbackSection(NodeBuilder $callbacks, $type) |
103
|
|
|
{ |
104
|
|
|
$callbacks |
105
|
5 |
|
->arrayNode($type) |
106
|
5 |
|
->useAttributeAsKey('name') |
107
|
5 |
|
->prototype('array') |
108
|
5 |
|
->children() |
109
|
5 |
|
->scalarNode('on')->end() |
110
|
5 |
|
->variableNode('do')->end() |
111
|
5 |
|
->variableNode('from')->end() |
112
|
5 |
|
->variableNode('to')->end() |
113
|
5 |
|
->scalarNode('disabled')->defaultValue(false)->end() |
114
|
5 |
|
->end() |
115
|
5 |
|
->end() |
116
|
5 |
|
->end(); |
117
|
5 |
|
} |
118
|
|
|
} |
119
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.