]> Raphaƫl G. Git Repositories - userbundle/blob - DependencyInjection/Configuration.php
Rename title in civility
[userbundle] / DependencyInjection / Configuration.php
1 <?php
2
3 namespace Rapsys\UserBundle\DependencyInjection;
4
5 use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6 use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8 /**
9 * This is the class that validates and merges configuration from your app/config files.
10 *
11 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
12 */
13 class Configuration implements ConfigurationInterface {
14 /**
15 * {@inheritdoc}
16 */
17 public function getConfigTreeBuilder() {
18 //Set tree builder
19 $treeBuilder = new TreeBuilder('rapsys_user');
20
21 //The bundle default values
22 $defaults = [
23 'class' => [
24 'group' => 'Rapsys\\UserBundle\\Entity\\Group',
25 'civility' => 'Rapsys\\UserBundle\\Entity\\Civility',
26 'user' => 'Rapsys\\UserBundle\\Entity\\User'
27 ],
28 'default' => [
29 'civility' => 'Mister',
30 'group' => [ 'User' ]
31 ],
32 'route' => [
33 'index' => [
34 'name' => 'rapsys_user_index',
35 'context' => []
36 ],
37 'login' => [
38 'name' => 'rapsys_user_login',
39 'context' => []
40 ],
41 'recover' => [
42 'name' => 'rapsys_user_recover',
43 'context' => []
44 ],
45 'recover_mail' => [
46 'name' => 'rapsys_user_recover_mail',
47 'context' => []
48 ],
49 'register' => [
50 'name' => 'rapsys_user_register',
51 'context' => []
52 ]
53 ],
54 'translate' => [],
55 'locales' => '%kernel.translator.fallbacks%',
56 'languages' => [
57 'en' => 'English'
58 ],
59 'contact' => [
60 'name' => 'John Doe',
61 'mail' => 'contact@example.com'
62 ],
63 'login' => [
64 'route' => ['index' => 'index_url'],
65 'view' => [
66 'name' => '@RapsysUser/form/login.html.twig',
67 'form' => 'Rapsys\UserBundle\Form\LoginType',
68 'context' => []
69 ]
70 ],
71 'recover' => [
72 'route' => ['index' => 'index_url', 'recover_mail' => 'recover_url'],
73 'view' => [
74 'name' => '@RapsysUser/form/recover.html.twig',
75 'form' => 'Rapsys\UserBundle\Form\RecoverType',
76 'context' => []
77 ],
78 'mail' => [
79 'subject' => 'Welcome back!',
80 'html' => '@RapsysUser/mail/recover.html.twig',
81 'text' => '@RapsysUser/mail/recover.text.twig',
82 'context' => []
83 ]
84 ],
85 'recover_mail' => [
86 'route' => ['index' => 'index_url', 'recover_mail' => 'recover_url'],
87 'view' => [
88 'name' => '@RapsysUser/form/recover_mail.html.twig',
89 'form' => 'Rapsys\UserBundle\Form\RecoverMailType',
90 'context' => []
91 ],
92 'mail' => [
93 'subject' => 'Welcome back!',
94 'html' => '@RapsysUser/mail/recover_mail.html.twig',
95 'text' => '@RapsysUser/mail/recover_mail.text.twig',
96 'context' => []
97 ]
98 ],
99 'register' => [
100 'route' => ['index' => 'index_url'],
101 'view' => [
102 'form' => 'Rapsys\UserBundle\Form\RegisterType',
103 'name' => '@RapsysUser/form/register.html.twig',
104 'context' => []
105 ],
106 'mail' => [
107 'subject' => 'Welcome!',
108 'html' => '@RapsysUser/mail/register.html.twig',
109 'text' => '@RapsysUser/mail/register.text.twig',
110 'context' => []
111 ]
112 ]
113 ];
114
115 //Here we define the parameters that are allowed to configure the bundle.
116 //TODO: see https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php for default value and description
117 //TODO: see http://symfony.com/doc/current/components/config/definition.html
118 //TODO: see fosuser DependencyInjection/Configuration.php
119 //XXX: use bin/console config:dump-reference to dump class infos
120
121 //Here we define the parameters that are allowed to configure the bundle.
122 $treeBuilder
123 //Parameters
124 ->getRootNode()
125 ->addDefaultsIfNotSet()
126 ->children()
127 ->arrayNode('class')
128 ->addDefaultsIfNotSet()
129 ->children()
130 ->scalarNode('group')->cannotBeEmpty()->defaultValue($defaults['class']['group'])->end()
131 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['class']['civility'])->end()
132 ->scalarNode('user')->cannotBeEmpty()->defaultValue($defaults['class']['user'])->end()
133 ->end()
134 ->end()
135 ->arrayNode('default')
136 ->addDefaultsIfNotSet()
137 ->children()
138 ->scalarNode('civility')->cannotBeEmpty()->defaultValue($defaults['default']['civility'])->end()
139 ->arrayNode('group')
140 ->treatNullLike(array())
141 ->defaultValue($defaults['default']['group'])
142 ->scalarPrototype()->end()
143 ->end()
144 ->end()
145 ->end()
146 ->arrayNode('route')
147 ->addDefaultsIfNotSet()
148 ->children()
149 ->arrayNode('index')
150 ->addDefaultsIfNotSet()
151 ->children()
152 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
153 ->arrayNode('context')
154 ->treatNullLike(array())
155 ->defaultValue($defaults['route']['index']['context'])
156 ->scalarPrototype()->end()
157 ->end()
158 ->end()
159 ->end()
160 ->arrayNode('login')
161 ->addDefaultsIfNotSet()
162 ->children()
163 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
164 ->arrayNode('context')
165 ->treatNullLike(array())
166 ->defaultValue($defaults['route']['login']['context'])
167 ->scalarPrototype()->end()
168 ->end()
169 ->end()
170 ->end()
171 ->arrayNode('recover')
172 ->addDefaultsIfNotSet()
173 ->children()
174 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
175 ->arrayNode('context')
176 ->treatNullLike(array())
177 ->defaultValue($defaults['route']['recover']['context'])
178 ->scalarPrototype()->end()
179 ->end()
180 ->end()
181 ->end()
182 ->arrayNode('recover_mail')
183 ->addDefaultsIfNotSet()
184 ->children()
185 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover_mail']['name'])->end()
186 ->arrayNode('context')
187 ->treatNullLike(array())
188 ->defaultValue($defaults['route']['recover_mail']['context'])
189 ->scalarPrototype()->end()
190 ->end()
191 ->end()
192 ->end()
193 ->arrayNode('register')
194 ->addDefaultsIfNotSet()
195 ->children()
196 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
197 ->arrayNode('context')
198 ->treatNullLike(array())
199 ->defaultValue($defaults['route']['register']['context'])
200 ->scalarPrototype()->end()
201 ->end()
202 ->end()
203 ->end()
204 ->end()
205 ->end()
206 ->arrayNode('translate')
207 ->treatNullLike(array())
208 ->defaultValue($defaults['translate'])
209 ->scalarPrototype()->end()
210 ->end()
211 ->scalarNode('locales')->cannotBeEmpty()->defaultValue($defaults['locales'])->end()
212 ->arrayNode('languages')
213 ->treatNullLike([])
214 ->defaultValue($defaults['languages'])
215 ->scalarPrototype()->end()
216 ->end()
217 ->arrayNode('contact')
218 ->addDefaultsIfNotSet()
219 ->children()
220 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['contact']['name'])->end()
221 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
222 ->end()
223 ->end()
224 ->arrayNode('login')
225 ->addDefaultsIfNotSet()
226 ->children()
227 ->arrayNode('route')
228 ->treatNullLike(array())
229 ->defaultValue($defaults['login']['route'])
230 ->scalarPrototype()->end()
231 ->end()
232 ->arrayNode('view')
233 ->addDefaultsIfNotSet()
234 ->children()
235 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
236 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
237 ->arrayNode('context')
238 ->treatNullLike(array())
239 ->defaultValue($defaults['login']['view']['context'])
240 ->variablePrototype()->end()
241 ->end()
242 ->end()
243 ->end()
244 ->end()
245 ->end()
246 ->arrayNode('recover')
247 ->addDefaultsIfNotSet()
248 ->children()
249 ->arrayNode('route')
250 ->treatNullLike(array())
251 ->defaultValue($defaults['recover']['route'])
252 ->scalarPrototype()->end()
253 ->end()
254 ->arrayNode('view')
255 ->addDefaultsIfNotSet()
256 ->children()
257 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
258 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
259 ->arrayNode('context')
260 ->treatNullLike(array())
261 ->defaultValue($defaults['recover']['view']['context'])
262 ->variablePrototype()->end()
263 ->end()
264 ->end()
265 ->end()
266 ->arrayNode('mail')
267 ->addDefaultsIfNotSet()
268 ->children()
269 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
270 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
271 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
272 ->arrayNode('context')
273 ->treatNullLike(array())
274 ->defaultValue($defaults['recover']['mail']['context'])
275 ->variablePrototype()->end()
276 ->end()
277 ->end()
278 ->end()
279 ->end()
280 ->end()
281 ->arrayNode('recover_mail')
282 ->addDefaultsIfNotSet()
283 ->children()
284 ->arrayNode('route')
285 ->treatNullLike(array())
286 ->defaultValue($defaults['recover_mail']['route'])
287 ->scalarPrototype()->end()
288 ->end()
289 ->arrayNode('view')
290 ->addDefaultsIfNotSet()
291 ->children()
292 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['view']['name'])->end()
293 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['view']['form'])->end()
294 ->arrayNode('context')
295 ->treatNullLike(array())
296 ->defaultValue($defaults['recover_mail']['view']['context'])
297 ->variablePrototype()->end()
298 ->end()
299 ->end()
300 ->end()
301 ->arrayNode('mail')
302 ->addDefaultsIfNotSet()
303 ->children()
304 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['mail']['subject'])->end()
305 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['mail']['html'])->end()
306 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['mail']['text'])->end()
307 ->arrayNode('context')
308 ->treatNullLike(array())
309 ->defaultValue($defaults['recover_mail']['mail']['context'])
310 ->variablePrototype()->end()
311 ->end()
312 ->end()
313 ->end()
314 ->end()
315 ->end()
316 ->arrayNode('register')
317 ->addDefaultsIfNotSet()
318 ->children()
319 ->arrayNode('route')
320 ->treatNullLike(array())
321 ->defaultValue($defaults['register']['route'])
322 ->scalarPrototype()->end()
323 ->end()
324 ->arrayNode('view')
325 ->addDefaultsIfNotSet()
326 ->children()
327 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
328 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
329 ->arrayNode('context')
330 ->treatNullLike(array())
331 ->defaultValue($defaults['register']['view']['context'])
332 ->variablePrototype()->end()
333 ->end()
334 ->end()
335 ->end()
336 ->arrayNode('mail')
337 ->addDefaultsIfNotSet()
338 ->children()
339 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
340 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
341 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
342 ->arrayNode('context')
343 ->treatNullLike(array())
344 ->defaultValue($defaults['register']['mail']['context'])
345 ->variablePrototype()->end()
346 ->end()
347 ->end()
348 ->end()
349 ->end()
350 ->end()
351 ->end()
352 ->end();
353
354 return $treeBuilder;
355 }
356 }