1 | <?php |
||
11 | abstract class AbstractResourceConfiguration implements ConfigurationInterface |
||
12 | { |
||
13 | const DEFAULT_KEY = 'default'; |
||
14 | |||
15 | /** |
||
16 | * @param array $resources |
||
17 | * |
||
18 | * @return ArrayNodeDefinition |
||
19 | */ |
||
20 | protected function createResourcesSection(array $resources = array()) |
||
21 | { |
||
22 | $builder = new TreeBuilder(); |
||
23 | $node = $builder->root('resources'); |
||
24 | $node->addDefaultsIfNotSet(); |
||
25 | $resourceNodes = $node->children(); |
||
26 | |||
27 | foreach ($resources as $resource => $defaults) { |
||
28 | $resourceNode = $resourceNodes |
||
29 | ->arrayNode($resource) |
||
30 | ->addDefaultsIfNotSet() |
||
31 | ; |
||
32 | |||
33 | $this->addClassesSection($resourceNode, $defaults['classes']); |
||
34 | |||
35 | if (isset($defaults['options'])) { |
||
36 | $this->createOptionsNode($resourceNode, $defaults['options']); |
||
37 | } |
||
38 | |||
39 | if (!isset($defaults['validation_groups'])) { |
||
40 | $defaults['validation_groups'] = array( |
||
41 | 'default' => array() |
||
42 | ); |
||
43 | } |
||
44 | |||
45 | $this->addValidationGroupsSection($resourceNode, $defaults['validation_groups']); |
||
46 | } |
||
47 | |||
48 | return $node; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @param ArrayNodeDefinition $node |
||
53 | * @param array $defaults |
||
54 | * |
||
55 | * @return ArrayNodeDefinition |
||
56 | */ |
||
57 | protected function addClassesSection(ArrayNodeDefinition $node, array $defaults = array()) |
||
92 | |||
93 | /** |
||
94 | * @param string $default |
||
95 | * |
||
96 | * @return ScalarNodeDefinition |
||
97 | */ |
||
98 | protected function createDriverNode($default = null) |
||
125 | |||
126 | protected function createOptionsNode(ArrayNodeDefinition $node, $default = 'default') |
||
127 | { |
||
128 | $node |
||
129 | ->children() |
||
130 | ->variableNode('options')->end() |
||
131 | ->end() |
||
132 | ; |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * @param string $default |
||
137 | * |
||
138 | * @return ScalarNodeDefinition |
||
139 | */ |
||
140 | protected function createInterfaceNode($default = null) |
||
157 | |||
158 | /** |
||
159 | * @param ArrayNodeDefinition $node |
||
160 | * @param array $validationGroups |
||
161 | */ |
||
162 | protected function addValidationGroupsSection(ArrayNodeDefinition $node, array $validationGroups = array()) |
||
185 | |||
186 | /** |
||
187 | * @param array|string $classes |
||
188 | * |
||
189 | * @return ArrayNodeDefinition |
||
190 | */ |
||
191 | protected function createFormsNode($classes) |
||
221 | |||
222 | protected function setDefaults(ArrayNodeDefinition $node, array $configs = array()) |
||
232 | } |
||
233 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: