]> Raphaël G. Git Repositories - userbundle/blob - DependencyInjection/Configuration.php
Add extra field on confirm url
[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 /**
18 * This is the class that validates and merges configuration from your app/config files.
19 *
20 * @link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
21 *
22 * {@inheritdoc}
23 */
24 class Configuration implements ConfigurationInterface {
25 /**
26 * {@inheritdoc}
27 */
28 public function getConfigTreeBuilder(): TreeBuilder {
29 //Set tree builder
30 $treeBuilder = new TreeBuilder('rapsys_user');
31
32 //The bundle default values
33 $defaults = [
34 'class' => [
35 'group' => 'Rapsys\\UserBundle\\Entity\\Group',
36 'civility' => 'Rapsys\\UserBundle\\Entity\\Civility',
37 'user' => 'Rapsys\\UserBundle\\Entity\\User'
38 ],
39 'default' => [
40 'civility' => 'Mister',
41 'group' => [ 'User' ]
42 ],
43 'route' => [
44 'confirm' => [
45 'name' => 'rapsys_user_confirm',
46 'context' => []
47 ],
48 'edit' => [
49 'name' => 'rapsys_user_edit',
50 'context' => []
51 ],
52 'index' => [
53 'name' => 'rapsys_user_index',
54 'context' => []
55 ],
56 'login' => [
57 'name' => 'rapsys_user_login',
58 'context' => []
59 ],
60 'recover' => [
61 'name' => 'rapsys_user_recover',
62 'context' => []
63 ],
64 'register' => [
65 'name' => 'rapsys_user_register',
66 'context' => []
67 ]
68 ],
69 'translate' => [],
70 'locales' => '%kernel.translator.fallbacks%',
71 'languages' => [
72 'en_gb' => 'English'
73 ],
74 'contact' => [
75 'title' => 'John Doe',
76 'mail' => 'contact@example.com'
77 ],
78 'context' => [],
79 'edit' => [
80 'route' => ['index' => 'index_url'],
81 'view' => [
82 'form' => 'Rapsys\UserBundle\Form\RegisterType',
83 'name' => '@RapsysUser/form/register.html.twig',
84 'context' => []
85 ]
86 ],
87 'login' => [
88 'route' => ['index' => 'index_url'],
89 'view' => [
90 'name' => '@RapsysUser/form/login.html.twig',
91 'form' => 'Rapsys\UserBundle\Form\LoginType',
92 'context' => []
93 ]
94 ],
95 'recover' => [
96 'route' => ['index' => 'index_url', 'recover' => 'recover_url'],
97 'view' => [
98 'name' => '@RapsysUser/form/recover.html.twig',
99 'form' => 'Rapsys\UserBundle\Form\RecoverType',
100 'context' => []
101 ],
102 'mail' => [
103 'subject' => 'Welcome back!',
104 'html' => '@RapsysUser/mail/recover.html.twig',
105 'text' => '@RapsysUser/mail/recover.text.twig',
106 'context' => []
107 ]
108 ],
109 'register' => [
110 'route' => ['index' => 'index_url', 'confirm' => 'confirm_url'],
111 'view' => [
112 'form' => 'Rapsys\UserBundle\Form\RegisterType',
113 'name' => '@RapsysUser/form/register.html.twig',
114 'context' => []
115 ],
116 'mail' => [
117 'subject' => 'Welcome!',
118 'html' => '@RapsysUser/mail/register.html.twig',
119 'text' => '@RapsysUser/mail/register.text.twig',
120 'context' => []
121 ]
122 ]
123 ];
124
125 /**
126 * Defines parameters allowed to configure the bundle
127 *
128 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
129 * @link http://symfony.com/doc/current/components/config/definition.html
130 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
131 *
132 * @see php bin/console config:dump-reference rapsys_user to dump default config
133 * @see php bin/console debug:config rapsys_user to dump config
134 */
135 $treeBuilder
136 //Parameters
137 ->getRootNode()
138 ->addDefaultsIfNotSet()
139 ->children()
140 ->arrayNode('class')
141 ->addDefaultsIfNotSet()
142 ->children()
143 ->scalarNode('group')->cannotBeEmpty()->defaultValue($defaults['class']['group'])->end()
144 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['class']['civility'])->end()
145 ->scalarNode('user')->cannotBeEmpty()->defaultValue($defaults['class']['user'])->end()
146 ->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('form')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['form'])->end()
265 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['name'])->end()
266 ->arrayNode('context')
267 ->treatNullLike([])
268 ->defaultValue($defaults['edit']['view']['context'])
269 ->variablePrototype()->end()
270 ->end()
271 ->end()
272 ->end()
273 ->end()
274 ->end()
275 ->arrayNode('login')
276 ->addDefaultsIfNotSet()
277 ->children()
278 ->arrayNode('route')
279 ->treatNullLike([])
280 ->defaultValue($defaults['login']['route'])
281 ->scalarPrototype()->end()
282 ->end()
283 ->arrayNode('view')
284 ->addDefaultsIfNotSet()
285 ->children()
286 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
287 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
288 ->arrayNode('context')
289 ->treatNullLike([])
290 ->defaultValue($defaults['login']['view']['context'])
291 ->variablePrototype()->end()
292 ->end()
293 ->end()
294 ->end()
295 ->end()
296 ->end()
297 ->arrayNode('recover')
298 ->addDefaultsIfNotSet()
299 ->children()
300 ->arrayNode('route')
301 ->treatNullLike([])
302 ->defaultValue($defaults['recover']['route'])
303 ->scalarPrototype()->end()
304 ->end()
305 ->arrayNode('view')
306 ->addDefaultsIfNotSet()
307 ->children()
308 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
309 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
310 ->arrayNode('context')
311 ->treatNullLike([])
312 ->defaultValue($defaults['recover']['view']['context'])
313 ->variablePrototype()->end()
314 ->end()
315 ->end()
316 ->end()
317 ->arrayNode('mail')
318 ->addDefaultsIfNotSet()
319 ->children()
320 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
321 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
322 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
323 ->arrayNode('context')
324 ->treatNullLike([])
325 ->defaultValue($defaults['recover']['mail']['context'])
326 ->variablePrototype()->end()
327 ->end()
328 ->end()
329 ->end()
330 ->end()
331 ->end()
332 ->arrayNode('register')
333 ->addDefaultsIfNotSet()
334 ->children()
335 ->arrayNode('route')
336 ->treatNullLike([])
337 ->defaultValue($defaults['register']['route'])
338 ->scalarPrototype()->end()
339 ->end()
340 ->arrayNode('view')
341 ->addDefaultsIfNotSet()
342 ->children()
343 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
344 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
345 ->arrayNode('context')
346 ->treatNullLike([])
347 ->defaultValue($defaults['register']['view']['context'])
348 ->variablePrototype()->end()
349 ->end()
350 ->end()
351 ->end()
352 ->arrayNode('mail')
353 ->addDefaultsIfNotSet()
354 ->children()
355 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
356 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
357 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
358 ->arrayNode('context')
359 ->treatNullLike([])
360 ->defaultValue($defaults['register']['mail']['context'])
361 ->variablePrototype()->end()
362 ->end()
363 ->end()
364 ->end()
365 ->end()
366 ->end()
367 ->end()
368 ->end();
369
370 return $treeBuilder;
371 }
372 }