]> Raphaël G. Git Repositories - userbundle/blob - DependencyInjection/Configuration.php
Set mail, password as optional field
[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 ->treatNullLike([])
142 ->defaultValue($defaults['class'])
143 ->scalarPrototype()->end()
144 ->end()
145 ->arrayNode('default')
146 ->addDefaultsIfNotSet()
147 ->children()
148 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['default']['civility'])->end()
149 ->arrayNode('group')
150 ->treatNullLike([])
151 ->defaultValue($defaults['default']['group'])
152 ->scalarPrototype()->end()
153 ->end()
154 ->end()
155 ->end()
156 ->arrayNode('route')
157 ->addDefaultsIfNotSet()
158 ->children()
159 ->arrayNode('confirm')
160 ->addDefaultsIfNotSet()
161 ->children()
162 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['confirm']['name'])->end()
163 ->arrayNode('context')
164 ->treatNullLike([])
165 ->defaultValue($defaults['route']['confirm']['context'])
166 ->scalarPrototype()->end()
167 ->end()
168 ->end()
169 ->end()
170 ->arrayNode('index')
171 ->addDefaultsIfNotSet()
172 ->children()
173 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
174 ->arrayNode('context')
175 ->treatNullLike([])
176 ->defaultValue($defaults['route']['index']['context'])
177 ->scalarPrototype()->end()
178 ->end()
179 ->end()
180 ->end()
181 ->arrayNode('edit')
182 ->addDefaultsIfNotSet()
183 ->children()
184 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['edit']['name'])->end()
185 ->arrayNode('context')
186 ->treatNullLike([])
187 ->defaultValue($defaults['route']['edit']['context'])
188 ->scalarPrototype()->end()
189 ->end()
190 ->end()
191 ->end()
192 ->arrayNode('login')
193 ->addDefaultsIfNotSet()
194 ->children()
195 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
196 ->arrayNode('context')
197 ->treatNullLike([])
198 ->defaultValue($defaults['route']['login']['context'])
199 ->scalarPrototype()->end()
200 ->end()
201 ->end()
202 ->end()
203 ->arrayNode('recover')
204 ->addDefaultsIfNotSet()
205 ->children()
206 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
207 ->arrayNode('context')
208 ->treatNullLike([])
209 ->defaultValue($defaults['route']['recover']['context'])
210 ->scalarPrototype()->end()
211 ->end()
212 ->end()
213 ->end()
214 ->arrayNode('register')
215 ->addDefaultsIfNotSet()
216 ->children()
217 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
218 ->arrayNode('context')
219 ->treatNullLike([])
220 ->defaultValue($defaults['route']['register']['context'])
221 ->scalarPrototype()->end()
222 ->end()
223 ->end()
224 ->end()
225 ->end()
226 ->end()
227 ->arrayNode('translate')
228 ->treatNullLike([])
229 ->defaultValue($defaults['translate'])
230 ->scalarPrototype()->end()
231 ->end()
232 ->scalarNode('locales')->cannotBeEmpty()->defaultValue($defaults['locales'])->end()
233 ->arrayNode('languages')
234 ->treatNullLike([])
235 ->defaultValue($defaults['languages'])
236 ->scalarPrototype()->end()
237 ->end()
238 ->arrayNode('contact')
239 ->addDefaultsIfNotSet()
240 ->children()
241 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['contact']['title'])->end()
242 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
243 ->end()
244 ->end()
245 ->arrayNode('context')
246 ->treatNullLike([])
247 ->defaultValue($defaults['context'])
248 ->variablePrototype()->end()
249 ->end()
250 ->arrayNode('edit')
251 ->addDefaultsIfNotSet()
252 ->children()
253 ->arrayNode('route')
254 ->treatNullLike([])
255 ->defaultValue($defaults['edit']['route'])
256 ->scalarPrototype()->end()
257 ->end()
258 ->arrayNode('view')
259 ->addDefaultsIfNotSet()
260 ->children()
261 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['form'])->end()
262 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['edit']['view']['name'])->end()
263 ->arrayNode('context')
264 ->treatNullLike([])
265 ->defaultValue($defaults['edit']['view']['context'])
266 ->variablePrototype()->end()
267 ->end()
268 ->end()
269 ->end()
270 ->end()
271 ->end()
272 ->arrayNode('login')
273 ->addDefaultsIfNotSet()
274 ->children()
275 ->arrayNode('route')
276 ->treatNullLike([])
277 ->defaultValue($defaults['login']['route'])
278 ->scalarPrototype()->end()
279 ->end()
280 ->arrayNode('view')
281 ->addDefaultsIfNotSet()
282 ->children()
283 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
284 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
285 ->arrayNode('context')
286 ->treatNullLike([])
287 ->defaultValue($defaults['login']['view']['context'])
288 ->variablePrototype()->end()
289 ->end()
290 ->end()
291 ->end()
292 ->end()
293 ->end()
294 ->arrayNode('recover')
295 ->addDefaultsIfNotSet()
296 ->children()
297 ->arrayNode('route')
298 ->treatNullLike([])
299 ->defaultValue($defaults['recover']['route'])
300 ->scalarPrototype()->end()
301 ->end()
302 ->arrayNode('view')
303 ->addDefaultsIfNotSet()
304 ->children()
305 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
306 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
307 ->arrayNode('context')
308 ->treatNullLike([])
309 ->defaultValue($defaults['recover']['view']['context'])
310 ->variablePrototype()->end()
311 ->end()
312 ->end()
313 ->end()
314 ->arrayNode('mail')
315 ->addDefaultsIfNotSet()
316 ->children()
317 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
318 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
319 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
320 ->arrayNode('context')
321 ->treatNullLike([])
322 ->defaultValue($defaults['recover']['mail']['context'])
323 ->variablePrototype()->end()
324 ->end()
325 ->end()
326 ->end()
327 ->end()
328 ->end()
329 ->arrayNode('register')
330 ->addDefaultsIfNotSet()
331 ->children()
332 ->arrayNode('route')
333 ->treatNullLike([])
334 ->defaultValue($defaults['register']['route'])
335 ->scalarPrototype()->end()
336 ->end()
337 ->arrayNode('view')
338 ->addDefaultsIfNotSet()
339 ->children()
340 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
341 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
342 ->arrayNode('context')
343 ->treatNullLike([])
344 ->defaultValue($defaults['register']['view']['context'])
345 ->variablePrototype()->end()
346 ->end()
347 ->end()
348 ->end()
349 ->arrayNode('mail')
350 ->addDefaultsIfNotSet()
351 ->children()
352 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
353 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
354 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
355 ->arrayNode('context')
356 ->treatNullLike([])
357 ->defaultValue($defaults['register']['mail']['context'])
358 ->variablePrototype()->end()
359 ->end()
360 ->end()
361 ->end()
362 ->end()
363 ->end()
364 ->end()
365 ->end();
366
367 return $treeBuilder;
368 }
369 }