]> Raphaël G. Git Repositories - userbundle/blob - DependencyInjection/Configuration.php
Cleanup
[userbundle] / DependencyInjection / Configuration.php
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Rapsys PackBundle 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 '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 'route' => ['index' => 'index_url', 'confirm' => 'confirm_url'],
114 'view' => [
115 'name' => '@RapsysUser/form/register.html.twig',
116 'form' => 'Rapsys\UserBundle\Form\RegisterType',
117 'context' => []
118 ],
119 'mail' => [
120 'subject' => 'Welcome!',
121 'html' => '@RapsysUser/mail/register.html.twig',
122 'text' => '@RapsysUser/mail/register.text.twig',
123 'context' => []
124 ]
125 ]
126 ];
127
128 /**
129 * Defines parameters allowed to configure the bundle
130 *
131 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
132 * @link http://symfony.com/doc/current/components/config/definition.html
133 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
134 *
135 * @see php bin/console config:dump-reference rapsys_user to dump default config
136 * @see php bin/console debug:config rapsys_user to dump config
137 */
138 $treeBuilder
139 //Parameters
140 ->getRootNode()
141 ->addDefaultsIfNotSet()
142 ->children()
143 ->arrayNode('class')
144 ->treatNullLike([])
145 ->defaultValue($defaults['class'])
146 ->scalarPrototype()->end()
147 ->end()
148 ->arrayNode('default')
149 ->addDefaultsIfNotSet()
150 ->children()
151 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['default']['civility'])->end()
152 ->arrayNode('group')
153 ->treatNullLike([])
154 ->defaultValue($defaults['default']['group'])
155 ->scalarPrototype()->end()
156 ->end()
157 ->end()
158 ->end()
159 ->arrayNode('route')
160 ->addDefaultsIfNotSet()
161 ->children()
162 ->arrayNode('confirm')
163 ->addDefaultsIfNotSet()
164 ->children()
165 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['confirm']['name'])->end()
166 ->arrayNode('context')
167 ->treatNullLike([])
168 ->defaultValue($defaults['route']['confirm']['context'])
169 ->scalarPrototype()->end()
170 ->end()
171 ->end()
172 ->end()
173 ->arrayNode('index')
174 ->addDefaultsIfNotSet()
175 ->children()
176 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
177 ->arrayNode('context')
178 ->treatNullLike([])
179 ->defaultValue($defaults['route']['index']['context'])
180 ->scalarPrototype()->end()
181 ->end()
182 ->end()
183 ->end()
184 ->arrayNode('edit')
185 ->addDefaultsIfNotSet()
186 ->children()
187 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['edit']['name'])->end()
188 ->arrayNode('context')
189 ->treatNullLike([])
190 ->defaultValue($defaults['route']['edit']['context'])
191 ->scalarPrototype()->end()
192 ->end()
193 ->end()
194 ->end()
195 ->arrayNode('login')
196 ->addDefaultsIfNotSet()
197 ->children()
198 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
199 ->arrayNode('context')
200 ->treatNullLike([])
201 ->defaultValue($defaults['route']['login']['context'])
202 ->scalarPrototype()->end()
203 ->end()
204 ->end()
205 ->end()
206 ->arrayNode('recover')
207 ->addDefaultsIfNotSet()
208 ->children()
209 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
210 ->arrayNode('context')
211 ->treatNullLike([])
212 ->defaultValue($defaults['route']['recover']['context'])
213 ->scalarPrototype()->end()
214 ->end()
215 ->end()
216 ->end()
217 ->arrayNode('register')
218 ->addDefaultsIfNotSet()
219 ->children()
220 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
221 ->arrayNode('context')
222 ->treatNullLike([])
223 ->defaultValue($defaults['route']['register']['context'])
224 ->scalarPrototype()->end()
225 ->end()
226 ->end()
227 ->end()
228 ->end()
229 ->end()
230 ->arrayNode('translate')
231 ->treatNullLike([])
232 ->defaultValue($defaults['translate'])
233 ->scalarPrototype()->end()
234 ->end()
235 ->scalarNode('locales')->cannotBeEmpty()->defaultValue($defaults['locales'])->end()
236 ->arrayNode('languages')
237 ->treatNullLike([])
238 ->defaultValue($defaults['languages'])
239 ->scalarPrototype()->end()
240 ->end()
241 ->arrayNode('contact')
242 ->addDefaultsIfNotSet()
243 ->children()
244 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['contact']['title'])->end()
245 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
246 ->end()
247 ->end()
248 ->arrayNode('context')
249 ->treatNullLike([])
250 ->defaultValue($defaults['context'])
251 ->variablePrototype()->end()
252 ->end()
253 ->arrayNode('edit')
254 ->addDefaultsIfNotSet()
255 ->children()
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('route')
337 ->treatNullLike([])
338 ->defaultValue($defaults['register']['route'])
339 ->scalarPrototype()->end()
340 ->end()
341 ->arrayNode('view')
342 ->addDefaultsIfNotSet()
343 ->children()
344 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
345 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
346 ->arrayNode('context')
347 ->treatNullLike([])
348 ->defaultValue($defaults['register']['view']['context'])
349 ->variablePrototype()->end()
350 ->end()
351 ->end()
352 ->end()
353 ->arrayNode('mail')
354 ->addDefaultsIfNotSet()
355 ->children()
356 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
357 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
358 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
359 ->arrayNode('context')
360 ->treatNullLike([])
361 ->defaultValue($defaults['register']['mail']['context'])
362 ->variablePrototype()->end()
363 ->end()
364 ->end()
365 ->end()
366 ->end()
367 ->end()
368 ->end()
369 ->end();
370
371 return $treeBuilder;
372 }
373 }