]> Raphaël G. Git Repositories - userbundle/blob - DependencyInjection/Configuration.php
Remove pseudonym and slug
[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 'locales' => '%kernel.translator.fallbacks%',
73 'languages' => [
74 'en_gb' => 'English'
75 ],
76 'contact' => [
77 'title' => 'John Doe',
78 'mail' => 'contact@example.com'
79 ],
80 'context' => [],
81 'edit' => [
82 'field' => [],
83 'route' => ['index' => 'index_url'],
84 'view' => [
85 'name' => '@RapsysUser/form/register.html.twig',
86 'edit' => 'Rapsys\UserBundle\Form\RegisterType',
87 'reset' => 'Rapsys\UserBundle\Form\LoginType',
88 'context' => []
89 ]
90 ],
91 'login' => [
92 'route' => ['index' => 'index_url'],
93 'view' => [
94 'name' => '@RapsysUser/form/login.html.twig',
95 'form' => 'Rapsys\UserBundle\Form\LoginType',
96 'context' => []
97 ]
98 ],
99 'recover' => [
100 'route' => ['index' => 'index_url', 'recover' => 'recover_url'],
101 'view' => [
102 'name' => '@RapsysUser/form/recover.html.twig',
103 'form' => 'Rapsys\UserBundle\Form\LoginType',
104 'context' => []
105 ],
106 'mail' => [
107 'subject' => 'Welcome back!',
108 'html' => '@RapsysUser/mail/recover.html.twig',
109 'text' => '@RapsysUser/mail/recover.text.twig',
110 'context' => []
111 ]
112 ],
113 'register' => [
114 'field' => [],
115 'route' => ['index' => 'index_url', 'confirm' => 'confirm_url'],
116 'view' => [
117 'name' => '@RapsysUser/form/register.html.twig',
118 'form' => 'Rapsys\UserBundle\Form\RegisterType',
119 'context' => []
120 ],
121 'mail' => [
122 'subject' => 'Welcome!',
123 'html' => '@RapsysUser/mail/register.html.twig',
124 'text' => '@RapsysUser/mail/register.text.twig',
125 'context' => []
126 ]
127 ]
128 ];
129
130 /**
131 * Defines parameters allowed to configure the bundle
132 *
133 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
134 * @link http://symfony.com/doc/current/components/config/definition.html
135 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
136 *
137 * @see php bin/console config:dump-reference rapsys_user to dump default config
138 * @see php bin/console debug:config rapsys_user to dump config
139 */
140 $treeBuilder
141 //Parameters
142 ->getRootNode()
143 ->addDefaultsIfNotSet()
144 ->children()
145 ->arrayNode('class')
146 ->treatNullLike([])
147 ->defaultValue($defaults['class'])
148 ->scalarPrototype()->end()
149 ->end()
150 ->arrayNode('default')
151 ->addDefaultsIfNotSet()
152 ->children()
153 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['default']['civility'])->end()
154 ->arrayNode('group')
155 ->treatNullLike([])
156 ->defaultValue($defaults['default']['group'])
157 ->scalarPrototype()->end()
158 ->end()
159 ->end()
160 ->end()
161 ->arrayNode('route')
162 ->addDefaultsIfNotSet()
163 ->children()
164 ->arrayNode('confirm')
165 ->addDefaultsIfNotSet()
166 ->children()
167 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['confirm']['name'])->end()
168 ->arrayNode('context')
169 ->treatNullLike([])
170 ->defaultValue($defaults['route']['confirm']['context'])
171 ->scalarPrototype()->end()
172 ->end()
173 ->end()
174 ->end()
175 ->arrayNode('index')
176 ->addDefaultsIfNotSet()
177 ->children()
178 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
179 ->arrayNode('context')
180 ->treatNullLike([])
181 ->defaultValue($defaults['route']['index']['context'])
182 ->scalarPrototype()->end()
183 ->end()
184 ->end()
185 ->end()
186 ->arrayNode('edit')
187 ->addDefaultsIfNotSet()
188 ->children()
189 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['edit']['name'])->end()
190 ->arrayNode('context')
191 ->treatNullLike([])
192 ->defaultValue($defaults['route']['edit']['context'])
193 ->scalarPrototype()->end()
194 ->end()
195 ->end()
196 ->end()
197 ->arrayNode('login')
198 ->addDefaultsIfNotSet()
199 ->children()
200 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
201 ->arrayNode('context')
202 ->treatNullLike([])
203 ->defaultValue($defaults['route']['login']['context'])
204 ->scalarPrototype()->end()
205 ->end()
206 ->end()
207 ->end()
208 ->arrayNode('recover')
209 ->addDefaultsIfNotSet()
210 ->children()
211 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
212 ->arrayNode('context')
213 ->treatNullLike([])
214 ->defaultValue($defaults['route']['recover']['context'])
215 ->scalarPrototype()->end()
216 ->end()
217 ->end()
218 ->end()
219 ->arrayNode('register')
220 ->addDefaultsIfNotSet()
221 ->children()
222 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
223 ->arrayNode('context')
224 ->treatNullLike([])
225 ->defaultValue($defaults['route']['register']['context'])
226 ->scalarPrototype()->end()
227 ->end()
228 ->end()
229 ->end()
230 ->end()
231 ->end()
232 ->arrayNode('translate')
233 ->treatNullLike([])
234 ->defaultValue($defaults['translate'])
235 ->scalarPrototype()->end()
236 ->end()
237 ->scalarNode('locales')->cannotBeEmpty()->defaultValue($defaults['locales'])->end()
238 ->arrayNode('languages')
239 ->treatNullLike([])
240 ->defaultValue($defaults['languages'])
241 ->scalarPrototype()->end()
242 ->end()
243 ->arrayNode('contact')
244 ->addDefaultsIfNotSet()
245 ->children()
246 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['contact']['title'])->end()
247 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
248 ->end()
249 ->end()
250 ->arrayNode('context')
251 ->treatNullLike([])
252 ->defaultValue($defaults['context'])
253 ->variablePrototype()->end()
254 ->end()
255 ->arrayNode('edit')
256 ->addDefaultsIfNotSet()
257 ->children()
258 ->arrayNode('field')
259 ->treatNullLike([])
260 ->defaultValue($defaults['edit']['field'])
261 ->variablePrototype()->end()
262 ->end()
263 ->arrayNode('route')
264 ->treatNullLike([])
265 ->defaultValue($defaults['edit']['route'])
266 ->scalarPrototype()->end()
267 ->end()
268 ->arrayNode('view')
269 ->addDefaultsIfNotSet()
270 ->children()
271 ->scalarNode('edit')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['edit'])->end()
272 ->scalarNode('reset')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['reset'])->end()
273 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['name'])->end()
274 ->arrayNode('context')
275 ->treatNullLike([])
276 ->defaultValue($defaults['edit']['view']['context'])
277 ->variablePrototype()->end()
278 ->end()
279 ->end()
280 ->end()
281 ->end()
282 ->end()
283 ->arrayNode('login')
284 ->addDefaultsIfNotSet()
285 ->children()
286 ->arrayNode('route')
287 ->treatNullLike([])
288 ->defaultValue($defaults['login']['route'])
289 ->scalarPrototype()->end()
290 ->end()
291 ->arrayNode('view')
292 ->addDefaultsIfNotSet()
293 ->children()
294 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
295 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
296 ->arrayNode('context')
297 ->treatNullLike([])
298 ->defaultValue($defaults['login']['view']['context'])
299 ->variablePrototype()->end()
300 ->end()
301 ->end()
302 ->end()
303 ->end()
304 ->end()
305 ->arrayNode('recover')
306 ->addDefaultsIfNotSet()
307 ->children()
308 ->arrayNode('route')
309 ->treatNullLike([])
310 ->defaultValue($defaults['recover']['route'])
311 ->scalarPrototype()->end()
312 ->end()
313 ->arrayNode('view')
314 ->addDefaultsIfNotSet()
315 ->children()
316 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
317 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
318 ->arrayNode('context')
319 ->treatNullLike([])
320 ->defaultValue($defaults['recover']['view']['context'])
321 ->variablePrototype()->end()
322 ->end()
323 ->end()
324 ->end()
325 ->arrayNode('mail')
326 ->addDefaultsIfNotSet()
327 ->children()
328 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
329 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
330 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
331 ->arrayNode('context')
332 ->treatNullLike([])
333 ->defaultValue($defaults['recover']['mail']['context'])
334 ->variablePrototype()->end()
335 ->end()
336 ->end()
337 ->end()
338 ->end()
339 ->end()
340 ->arrayNode('register')
341 ->addDefaultsIfNotSet()
342 ->children()
343 ->arrayNode('field')
344 ->treatNullLike([])
345 ->defaultValue($defaults['register']['field'])
346 ->variablePrototype()->end()
347 ->end()
348 ->arrayNode('route')
349 ->treatNullLike([])
350 ->defaultValue($defaults['register']['route'])
351 ->scalarPrototype()->end()
352 ->end()
353 ->arrayNode('view')
354 ->addDefaultsIfNotSet()
355 ->children()
356 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
357 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
358 ->arrayNode('context')
359 ->treatNullLike([])
360 ->defaultValue($defaults['register']['view']['context'])
361 ->variablePrototype()->end()
362 ->end()
363 ->end()
364 ->end()
365 ->arrayNode('mail')
366 ->addDefaultsIfNotSet()
367 ->children()
368 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
369 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
370 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
371 ->arrayNode('context')
372 ->treatNullLike([])
373 ->defaultValue($defaults['register']['mail']['context'])
374 ->variablePrototype()->end()
375 ->end()
376 ->end()
377 ->end()
378 ->end()
379 ->end()
380 ->end()
381 ->end();
382
383 return $treeBuilder;
384 }
385 }