]> Raphaël G. Git Repositories - userbundle/blob - DependencyInjection/Configuration.php
Replace disabled with enable
[userbundle] / DependencyInjection / Configuration.php
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Rapsys UserBundle package.
5 *
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Rapsys\UserBundle\DependencyInjection;
13
14 use Symfony\Component\Config\Definition\Builder\TreeBuilder;
15 use Symfony\Component\Config\Definition\ConfigurationInterface;
16
17 use Rapsys\UserBundle\RapsysUserBundle;
18
19 /**
20 * This is the class that validates and merges configuration from your app/config files.
21 *
22 * @link http://symfony.com/doc/current/cookbook/bundles/configuration.html
23 *
24 * {@inheritdoc}
25 */
26 class Configuration implements ConfigurationInterface {
27 /**
28 * {@inheritdoc}
29 */
30 public function getConfigTreeBuilder(): TreeBuilder {
31 //Set tree builder
32 $treeBuilder = new TreeBuilder(RapsysUserBundle::getAlias());
33
34 //The bundle default values
35 $defaults = [
36 'class' => [
37 'group' => 'Rapsys\\UserBundle\\Entity\\Group',
38 'civility' => 'Rapsys\\UserBundle\\Entity\\Civility',
39 'user' => 'Rapsys\\UserBundle\\Entity\\User'
40 ],
41 'default' => [
42 'civility' => 'Mister',
43 'group' => [ 'User' ]
44 ],
45 'route' => [
46 'confirm' => [
47 'name' => 'rapsys_user_confirm',
48 'context' => []
49 ],
50 'edit' => [
51 'name' => 'rapsys_user_edit',
52 'context' => []
53 ],
54 'index' => [
55 'name' => 'rapsys_user_index',
56 'context' => []
57 ],
58 'login' => [
59 'name' => 'rapsys_user_login',
60 'context' => []
61 ],
62 'recover' => [
63 'name' => 'rapsys_user_recover',
64 'context' => []
65 ],
66 'register' => [
67 'name' => 'rapsys_user_register',
68 'context' => []
69 ]
70 ],
71 'translate' => [],
72 'languages' => [
73 'en_gb' => 'English'
74 ],
75 'contact' => [
76 'address' => 'contact@example.com',
77 'name' => 'John Doe'
78 ],
79 'context' => [],
80 'edit' => [
81 'field' => [],
82 'route' => ['index' => 'index_url'],
83 'view' => [
84 'name' => '@RapsysUser/form/register.html.twig',
85 'edit' => 'Rapsys\UserBundle\Form\RegisterType',
86 'reset' => 'Rapsys\UserBundle\Form\LoginType',
87 'context' => []
88 ]
89 ],
90 'login' => [
91 'route' => ['index' => 'index_url'],
92 'view' => [
93 'name' => '@RapsysUser/form/login.html.twig',
94 'form' => 'Rapsys\UserBundle\Form\LoginType',
95 'context' => []
96 ]
97 ],
98 'recover' => [
99 'route' => ['index' => 'index_url', 'recover' => 'recover_url'],
100 'view' => [
101 'name' => '@RapsysUser/form/recover.html.twig',
102 'form' => 'Rapsys\UserBundle\Form\LoginType',
103 'context' => []
104 ],
105 'mail' => [
106 'subject' => 'Welcome back!',
107 'html' => '@RapsysUser/mail/recover.html.twig',
108 'text' => '@RapsysUser/mail/recover.text.twig',
109 'context' => []
110 ]
111 ],
112 'register' => [
113 'field' => [],
114 'route' => ['index' => 'index_url', 'confirm' => 'confirm_url'],
115 'view' => [
116 'name' => '@RapsysUser/form/register.html.twig',
117 'form' => 'Rapsys\UserBundle\Form\RegisterType',
118 'context' => []
119 ],
120 'mail' => [
121 'subject' => 'Welcome!',
122 'html' => '@RapsysUser/mail/register.html.twig',
123 'text' => '@RapsysUser/mail/register.text.twig',
124 'context' => []
125 ]
126 ]
127 ];
128
129 /**
130 * Defines parameters allowed to configure the bundle
131 *
132 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
133 * @link http://symfony.com/doc/current/components/config/definition.html
134 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
135 *
136 * @see php bin/console config:dump-reference rapsys_user to dump default config
137 * @see php bin/console debug:config rapsys_user to dump config
138 */
139 $treeBuilder
140 //Parameters
141 ->getRootNode()
142 ->addDefaultsIfNotSet()
143 ->children()
144 ->arrayNode('class')
145 ->treatNullLike([])
146 ->defaultValue($defaults['class'])
147 ->scalarPrototype()->end()
148 ->end()
149 ->arrayNode('default')
150 ->treatNullLike([])
151 ->defaultValue($defaults['default'])
152 ->variablePrototype()->end()
153 ->end()
154 ->arrayNode('route')
155 ->addDefaultsIfNotSet()
156 ->children()
157 ->arrayNode('confirm')
158 ->addDefaultsIfNotSet()
159 ->children()
160 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['confirm']['name'])->end()
161 ->arrayNode('context')
162 ->treatNullLike([])
163 ->defaultValue($defaults['route']['confirm']['context'])
164 ->scalarPrototype()->end()
165 ->end()
166 ->end()
167 ->end()
168 ->arrayNode('index')
169 ->addDefaultsIfNotSet()
170 ->children()
171 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
172 ->arrayNode('context')
173 ->treatNullLike([])
174 ->defaultValue($defaults['route']['index']['context'])
175 ->scalarPrototype()->end()
176 ->end()
177 ->end()
178 ->end()
179 ->arrayNode('edit')
180 ->addDefaultsIfNotSet()
181 ->children()
182 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['edit']['name'])->end()
183 ->arrayNode('context')
184 ->treatNullLike([])
185 ->defaultValue($defaults['route']['edit']['context'])
186 ->scalarPrototype()->end()
187 ->end()
188 ->end()
189 ->end()
190 ->arrayNode('login')
191 ->addDefaultsIfNotSet()
192 ->children()
193 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
194 ->arrayNode('context')
195 ->treatNullLike([])
196 ->defaultValue($defaults['route']['login']['context'])
197 ->scalarPrototype()->end()
198 ->end()
199 ->end()
200 ->end()
201 ->arrayNode('recover')
202 ->addDefaultsIfNotSet()
203 ->children()
204 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
205 ->arrayNode('context')
206 ->treatNullLike([])
207 ->defaultValue($defaults['route']['recover']['context'])
208 ->scalarPrototype()->end()
209 ->end()
210 ->end()
211 ->end()
212 ->arrayNode('register')
213 ->addDefaultsIfNotSet()
214 ->children()
215 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
216 ->arrayNode('context')
217 ->treatNullLike([])
218 ->defaultValue($defaults['route']['register']['context'])
219 ->scalarPrototype()->end()
220 ->end()
221 ->end()
222 ->end()
223 ->end()
224 ->end()
225 ->arrayNode('translate')
226 ->treatNullLike([])
227 ->defaultValue($defaults['translate'])
228 ->scalarPrototype()->end()
229 ->end()
230 #TODO: see if we can't prevent key normalisation with ->normalizeKeys(false)
231 ->arrayNode('languages')
232 ->treatNullLike([])
233 ->defaultValue($defaults['languages'])
234 ->scalarPrototype()->end()
235 ->end()
236 ->arrayNode('contact')
237 ->addDefaultsIfNotSet()
238 ->children()
239 ->scalarNode('address')->cannotBeEmpty()->defaultValue($defaults['contact']['address'])->end()
240 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['contact']['name'])->end()
241 ->end()
242 ->end()
243 ->arrayNode('context')
244 ->treatNullLike([])
245 ->defaultValue($defaults['context'])
246 ->variablePrototype()->end()
247 ->end()
248 ->arrayNode('edit')
249 ->addDefaultsIfNotSet()
250 ->children()
251 ->arrayNode('field')
252 ->treatNullLike([])
253 ->defaultValue($defaults['edit']['field'])
254 ->variablePrototype()->end()
255 ->end()
256 ->arrayNode('route')
257 ->treatNullLike([])
258 ->defaultValue($defaults['edit']['route'])
259 ->scalarPrototype()->end()
260 ->end()
261 ->arrayNode('view')
262 ->addDefaultsIfNotSet()
263 ->children()
264 ->scalarNode('edit')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['edit'])->end()
265 ->scalarNode('reset')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['reset'])->end()
266 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['name'])->end()
267 ->arrayNode('context')
268 ->treatNullLike([])
269 ->defaultValue($defaults['edit']['view']['context'])
270 ->variablePrototype()->end()
271 ->end()
272 ->end()
273 ->end()
274 ->end()
275 ->end()
276 ->arrayNode('login')
277 ->addDefaultsIfNotSet()
278 ->children()
279 ->arrayNode('route')
280 ->treatNullLike([])
281 ->defaultValue($defaults['login']['route'])
282 ->scalarPrototype()->end()
283 ->end()
284 ->arrayNode('view')
285 ->addDefaultsIfNotSet()
286 ->children()
287 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
288 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
289 ->arrayNode('context')
290 ->treatNullLike([])
291 ->defaultValue($defaults['login']['view']['context'])
292 ->variablePrototype()->end()
293 ->end()
294 ->end()
295 ->end()
296 ->end()
297 ->end()
298 ->arrayNode('recover')
299 ->addDefaultsIfNotSet()
300 ->children()
301 ->arrayNode('route')
302 ->treatNullLike([])
303 ->defaultValue($defaults['recover']['route'])
304 ->scalarPrototype()->end()
305 ->end()
306 ->arrayNode('view')
307 ->addDefaultsIfNotSet()
308 ->children()
309 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
310 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
311 ->arrayNode('context')
312 ->treatNullLike([])
313 ->defaultValue($defaults['recover']['view']['context'])
314 ->variablePrototype()->end()
315 ->end()
316 ->end()
317 ->end()
318 ->arrayNode('mail')
319 ->addDefaultsIfNotSet()
320 ->children()
321 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
322 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
323 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
324 ->arrayNode('context')
325 ->treatNullLike([])
326 ->defaultValue($defaults['recover']['mail']['context'])
327 ->variablePrototype()->end()
328 ->end()
329 ->end()
330 ->end()
331 ->end()
332 ->end()
333 ->arrayNode('register')
334 ->addDefaultsIfNotSet()
335 ->children()
336 ->arrayNode('field')
337 ->treatNullLike([])
338 ->defaultValue($defaults['register']['field'])
339 ->variablePrototype()->end()
340 ->end()
341 ->arrayNode('route')
342 ->treatNullLike([])
343 ->defaultValue($defaults['register']['route'])
344 ->scalarPrototype()->end()
345 ->end()
346 ->arrayNode('view')
347 ->addDefaultsIfNotSet()
348 ->children()
349 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
350 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
351 ->arrayNode('context')
352 ->treatNullLike([])
353 ->defaultValue($defaults['register']['view']['context'])
354 ->variablePrototype()->end()
355 ->end()
356 ->end()
357 ->end()
358 ->arrayNode('mail')
359 ->addDefaultsIfNotSet()
360 ->children()
361 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
362 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
363 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
364 ->arrayNode('context')
365 ->treatNullLike([])
366 ->defaultValue($defaults['register']['mail']['context'])
367 ->variablePrototype()->end()
368 ->end()
369 ->end()
370 ->end()
371 ->end()
372 ->end()
373 ->end()
374 ->end();
375
376 return $treeBuilder;
377 }
378 }