1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Khusseini\PimcoreRadBrickBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
6
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeBuilder; |
7
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
8
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* This is the class that validates and merges configuration from your app/config files. |
12
|
|
|
* |
13
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html} |
14
|
|
|
*/ |
15
|
|
|
class Configuration implements ConfigurationInterface |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* {@inheritdoc} |
19
|
|
|
*/ |
20
|
3 |
|
public function getConfigTreeBuilder() |
21
|
|
|
{ |
22
|
3 |
|
$treeBuilder = new TreeBuilder(); |
23
|
|
|
/** |
24
|
|
|
* @var ArrayNodeDefinition |
25
|
|
|
*/ |
26
|
3 |
|
$rootNode = $treeBuilder->root('pimcore_rad_brick'); |
|
|
|
|
27
|
|
|
|
28
|
3 |
|
$this->addDatasourcesSection($rootNode); |
29
|
3 |
|
$this->addAreabrickSection($rootNode); |
30
|
|
|
|
31
|
3 |
|
return $treeBuilder; |
32
|
|
|
} |
33
|
|
|
|
34
|
3 |
|
protected function addCommonAreabrick(NodeBuilder $builder): void |
35
|
|
|
{ |
36
|
|
|
$builder |
37
|
3 |
|
->scalarNode('class') |
38
|
3 |
|
->info('Use a predefined service instead of a newly created one.') |
39
|
3 |
|
->end(); |
40
|
|
|
$builder |
41
|
3 |
|
->arrayNode('options') |
42
|
3 |
|
->info('Set options for areabrick. (Makes only sense in combination with `class`)') |
43
|
3 |
|
->useAttributeAsKey('name') |
44
|
3 |
|
->scalarPrototype() |
45
|
3 |
|
->end() |
46
|
3 |
|
->end(); |
|
|
|
|
47
|
|
|
$builder |
48
|
3 |
|
->scalarNode('label') |
49
|
3 |
|
->info('Specify a label for the admin UI.') |
50
|
3 |
|
->end(); |
51
|
|
|
$builder |
52
|
3 |
|
->scalarNode('icon') |
53
|
3 |
|
->info('Specify an icon for the admin UI.') |
54
|
3 |
|
->end(); |
55
|
|
|
$builder |
56
|
3 |
|
->scalarNode('open') |
57
|
3 |
|
->info('Set HTML prepended to the brick\'s contents.') |
58
|
3 |
|
->defaultValue('') |
59
|
3 |
|
->end(); |
60
|
|
|
$builder |
61
|
3 |
|
->scalarNode('close') |
62
|
3 |
|
->info('Set HTML appended to the brick\'s contents.') |
63
|
3 |
|
->defaultValue('') |
64
|
3 |
|
->end(); |
65
|
|
|
$builder |
66
|
3 |
|
->booleanNode('use_edit') |
67
|
3 |
|
->info('Use a separate edit template.') |
68
|
3 |
|
->defaultValue(false) |
69
|
3 |
|
->end(); |
70
|
3 |
|
} |
71
|
|
|
|
72
|
3 |
|
protected function addGroupsAreabrick(NodeBuilder $builder): void |
73
|
|
|
{ |
74
|
|
|
$builder |
75
|
3 |
|
->variableNode('groups') |
76
|
3 |
|
->info('Define groups for areabrick.') |
77
|
3 |
|
->defaultValue([]) |
78
|
3 |
|
->end(); |
79
|
3 |
|
} |
80
|
|
|
|
81
|
3 |
|
protected function addDatasourcesAreabrick(NodeBuilder $builder): void |
82
|
|
|
{ |
83
|
|
|
$builder |
84
|
3 |
|
->arrayNode('datasources') |
85
|
3 |
|
->info('Configure datasources to use in view template') |
86
|
3 |
|
->useAttributeAsKey('name') |
87
|
3 |
|
->arrayPrototype() |
88
|
3 |
|
->children() |
89
|
3 |
|
->scalarNode('id') |
90
|
3 |
|
->info('Provide the id of the datasource to use') |
91
|
3 |
|
->end() |
92
|
3 |
|
->arrayNode('conditions') |
|
|
|
|
93
|
3 |
|
->info('Configure conditions for datasource.') |
94
|
3 |
|
->scalarPrototype() |
95
|
3 |
|
->end() |
96
|
3 |
|
->end() |
97
|
3 |
|
->arrayNode('args') |
98
|
3 |
|
->info('Configure arguments to pass to method call') |
99
|
3 |
|
->useAttributeAsKey('name') |
100
|
3 |
|
->variablePrototype() |
101
|
3 |
|
->end() |
102
|
3 |
|
->end() |
103
|
3 |
|
->end() |
104
|
3 |
|
->end() |
105
|
3 |
|
->end(); |
106
|
3 |
|
} |
107
|
|
|
|
108
|
3 |
|
protected function addEditableAreabrick(NodeBuilder $builder): void |
109
|
|
|
{ |
110
|
|
|
$builder |
111
|
3 |
|
->arrayNode('editables') |
112
|
3 |
|
->info('Define editables available in templates.') |
113
|
3 |
|
->requiresAtLeastOneElement() |
114
|
3 |
|
->useAttributeAsKey('name') |
115
|
3 |
|
->arrayPrototype() |
116
|
3 |
|
->children() |
117
|
3 |
|
->scalarNode('type') |
118
|
3 |
|
->info('Editable type') |
119
|
3 |
|
->isRequired() |
120
|
3 |
|
->cannotBeEmpty() |
121
|
3 |
|
->end() |
122
|
3 |
|
->variableNode('options') |
|
|
|
|
123
|
3 |
|
->info('Editable options') |
124
|
3 |
|
->defaultValue([]) |
125
|
3 |
|
->end() |
126
|
3 |
|
->scalarNode('instances') |
127
|
3 |
|
->info('Provide the number of instances.') |
128
|
3 |
|
->end() |
129
|
3 |
|
->scalarNode('group') |
130
|
3 |
|
->info('Specify the name of the group this editable belongs to.') |
131
|
3 |
|
->end() |
132
|
3 |
|
->arrayNode('map') |
133
|
3 |
|
->info('Map data from other editables') |
134
|
3 |
|
->arrayPrototype() |
135
|
3 |
|
->children() |
136
|
3 |
|
->scalarNode('source') |
137
|
3 |
|
->info('Expression to get the value') |
138
|
3 |
|
->isRequired() |
139
|
3 |
|
->cannotBeEmpty() |
140
|
3 |
|
->end() |
141
|
3 |
|
->scalarNode('target') |
142
|
3 |
|
->info('Path to property to be updated') |
143
|
3 |
|
->isRequired() |
144
|
3 |
|
->cannotBeEmpty() |
145
|
3 |
|
->end() |
146
|
3 |
|
->end() |
147
|
3 |
|
->end() |
148
|
3 |
|
->end() |
149
|
3 |
|
->arrayNode('datasource') |
150
|
3 |
|
->info('Bind editable to a datasource') |
151
|
3 |
|
->children() |
152
|
3 |
|
->scalarNode('name') |
153
|
3 |
|
->info('The name of the datasource') |
154
|
3 |
|
->end() |
155
|
3 |
|
->scalarNode('id') |
156
|
3 |
|
->info('The id to use for each item (uses expression language)') |
157
|
3 |
|
->end() |
158
|
3 |
|
->end() |
159
|
3 |
|
->end(); |
160
|
3 |
|
} |
161
|
|
|
|
162
|
3 |
|
protected function addAreabrickSection(ArrayNodeDefinition $node): void |
163
|
|
|
{ |
164
|
|
|
$prototype = $node |
165
|
3 |
|
->children() |
166
|
3 |
|
->arrayNode('areabricks') |
167
|
3 |
|
->useAttributeAsKey('name') |
168
|
3 |
|
->arrayPrototype() |
169
|
3 |
|
->children(); |
170
|
|
|
|
171
|
3 |
|
$this->addCommonAreabrick($prototype); |
172
|
3 |
|
$this->addGroupsAreabrick($prototype); |
173
|
3 |
|
$this->addDatasourcesAreabrick($prototype); |
174
|
3 |
|
$this->addEditableAreabrick($prototype); |
175
|
|
|
|
176
|
3 |
|
$prototype->end()->end()->end(); |
177
|
3 |
|
} |
178
|
|
|
|
179
|
3 |
|
protected function addDatasourcesSection(ArrayNodeDefinition $node): void |
180
|
|
|
{ |
181
|
|
|
$node |
182
|
3 |
|
->children() |
183
|
3 |
|
->arrayNode('datasources') |
184
|
3 |
|
->info('Define datasource available in areabricks.') |
185
|
3 |
|
->useAttributeAsKey('name') |
186
|
3 |
|
->arrayPrototype() |
187
|
3 |
|
->children() |
188
|
|
|
|
189
|
3 |
|
->scalarNode('service_id') |
190
|
3 |
|
->info('Provide a Symfony service id') |
191
|
3 |
|
->isRequired() |
192
|
3 |
|
->cannotBeEmpty() |
193
|
3 |
|
->end() |
194
|
|
|
|
195
|
3 |
|
->scalarNode('method') |
|
|
|
|
196
|
3 |
|
->info('Method to be called on service') |
197
|
3 |
|
->isRequired() |
198
|
3 |
|
->cannotBeEmpty() |
199
|
3 |
|
->end() |
200
|
|
|
|
201
|
3 |
|
->arrayNode('args') |
202
|
3 |
|
->variablePrototype() |
203
|
3 |
|
->info('Method arguments. Expressions can be used here') |
204
|
3 |
|
->end() |
205
|
3 |
|
->end() |
206
|
|
|
|
207
|
3 |
|
->end() |
208
|
3 |
|
->end() |
209
|
3 |
|
->end() |
210
|
3 |
|
->end(); |
211
|
3 |
|
} |
212
|
|
|
} |
213
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.