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