]> Raphaƫl G. Git Repositories - userbundle/blob - DependencyInjection/Configuration.php
Add default title and group
[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 'title' => 'Rapsys\\UserBundle\\Entity\\Title',
26 'user' => 'Rapsys\\UserBundle\\Entity\\User'
27 ],
28 'default' => [
29 'title' => '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 'contact' => [
55 'name' => 'John Doe',
56 'mail' => 'contact@example.com'
57 ],
58 'login' => [
59 'route' => ['index' => 'index_url'],
60 'view' => [
61 'name' => '@RapsysUser/form/login.html.twig',
62 'form' => 'Rapsys\UserBundle\Form\LoginType',
63 'context' => []
64 ]
65 ],
66 'recover' => [
67 'route' => ['index' => 'index_url', 'recover_mail' => 'recover_url'],
68 'view' => [
69 'name' => '@RapsysUser/form/recover.html.twig',
70 'form' => 'Rapsys\UserBundle\Form\RecoverType',
71 'context' => []
72 ],
73 'mail' => [
74 'subject' => 'Welcome back!',
75 'html' => '@RapsysUser/mail/recover.html.twig',
76 'text' => '@RapsysUser/mail/recover.text.twig',
77 'context' => []
78 ]
79 ],
80 'recover_mail' => [
81 'route' => ['index' => 'index_url', 'recover_mail' => 'recover_url'],
82 'view' => [
83 'name' => '@RapsysUser/form/recover_mail.html.twig',
84 'form' => 'Rapsys\UserBundle\Form\RecoverMailType',
85 'context' => []
86 ],
87 'mail' => [
88 'subject' => 'Welcome back!',
89 'html' => '@RapsysUser/mail/recover_mail.html.twig',
90 'text' => '@RapsysUser/mail/recover_mail.text.twig',
91 'context' => []
92 ]
93 ],
94 'register' => [
95 'route' => ['index' => 'index_url'],
96 'view' => [
97 'form' => 'Rapsys\UserBundle\Form\RegisterType',
98 'name' => '@RapsysUser/form/register.html.twig',
99 'context' => []
100 ],
101 'mail' => [
102 'subject' => 'Welcome!',
103 'html' => '@RapsysUser/mail/register.html.twig',
104 'text' => '@RapsysUser/mail/register.text.twig',
105 'context' => []
106 ]
107 ]
108 ];
109
110 //Here we define the parameters that are allowed to configure the bundle.
111 //TODO: see https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php for default value and description
112 //TODO: see http://symfony.com/doc/current/components/config/definition.html
113 //TODO: see fosuser DependencyInjection/Configuration.php
114 //XXX: use bin/console config:dump-reference to dump class infos
115
116 //Here we define the parameters that are allowed to configure the bundle.
117 $treeBuilder
118 //Parameters
119 ->getRootNode()
120 ->addDefaultsIfNotSet()
121 ->children()
122 ->arrayNode('class')
123 ->addDefaultsIfNotSet()
124 ->children()
125 ->scalarNode('group')->cannotBeEmpty()->defaultValue($defaults['class']['group'])->end()
126 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['class']['title'])->end()
127 ->scalarNode('user')->cannotBeEmpty()->defaultValue($defaults['class']['user'])->end()
128 ->end()
129 ->end()
130 ->arrayNode('default')
131 ->addDefaultsIfNotSet()
132 ->children()
133 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['default']['title'])->end()
134 ->arrayNode('group')
135 ->treatNullLike(array())
136 ->defaultValue($defaults['default']['group'])
137 ->scalarPrototype()->end()
138 ->end()
139 ->end()
140 ->end()
141 ->arrayNode('route')
142 ->addDefaultsIfNotSet()
143 ->children()
144 ->arrayNode('index')
145 ->addDefaultsIfNotSet()
146 ->children()
147 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['index']['name'])->end()
148 ->arrayNode('context')
149 ->treatNullLike(array())
150 ->defaultValue($defaults['route']['index']['context'])
151 ->scalarPrototype()->end()
152 ->end()
153 ->end()
154 ->end()
155 ->arrayNode('login')
156 ->addDefaultsIfNotSet()
157 ->children()
158 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['login']['name'])->end()
159 ->arrayNode('context')
160 ->treatNullLike(array())
161 ->defaultValue($defaults['route']['login']['context'])
162 ->scalarPrototype()->end()
163 ->end()
164 ->end()
165 ->end()
166 ->arrayNode('recover')
167 ->addDefaultsIfNotSet()
168 ->children()
169 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover']['name'])->end()
170 ->arrayNode('context')
171 ->treatNullLike(array())
172 ->defaultValue($defaults['route']['recover']['context'])
173 ->scalarPrototype()->end()
174 ->end()
175 ->end()
176 ->end()
177 ->arrayNode('recover_mail')
178 ->addDefaultsIfNotSet()
179 ->children()
180 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['recover_mail']['name'])->end()
181 ->arrayNode('context')
182 ->treatNullLike(array())
183 ->defaultValue($defaults['route']['recover_mail']['context'])
184 ->scalarPrototype()->end()
185 ->end()
186 ->end()
187 ->end()
188 ->arrayNode('register')
189 ->addDefaultsIfNotSet()
190 ->children()
191 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['route']['register']['name'])->end()
192 ->arrayNode('context')
193 ->treatNullLike(array())
194 ->defaultValue($defaults['route']['register']['context'])
195 ->scalarPrototype()->end()
196 ->end()
197 ->end()
198 ->end()
199 ->end()
200 ->end()
201 ->arrayNode('contact')
202 ->addDefaultsIfNotSet()
203 ->children()
204 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['contact']['name'])->end()
205 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
206 ->end()
207 ->end()
208 ->arrayNode('login')
209 ->addDefaultsIfNotSet()
210 ->children()
211 ->arrayNode('route')
212 ->treatNullLike(array())
213 ->defaultValue($defaults['login']['route'])
214 ->scalarPrototype()->end()
215 ->end()
216 ->arrayNode('view')
217 ->addDefaultsIfNotSet()
218 ->children()
219 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['login']['view']['name'])->end()
220 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['login']['view']['form'])->end()
221 ->arrayNode('context')
222 ->treatNullLike(array())
223 ->defaultValue($defaults['login']['view']['context'])
224 ->variablePrototype()->end()
225 ->end()
226 ->end()
227 ->end()
228 ->end()
229 ->end()
230 ->arrayNode('recover')
231 ->addDefaultsIfNotSet()
232 ->children()
233 ->arrayNode('route')
234 ->treatNullLike(array())
235 ->defaultValue($defaults['recover']['route'])
236 ->scalarPrototype()->end()
237 ->end()
238 ->arrayNode('view')
239 ->addDefaultsIfNotSet()
240 ->children()
241 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['name'])->end()
242 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover']['view']['form'])->end()
243 ->arrayNode('context')
244 ->treatNullLike(array())
245 ->defaultValue($defaults['recover']['view']['context'])
246 ->variablePrototype()->end()
247 ->end()
248 ->end()
249 ->end()
250 ->arrayNode('mail')
251 ->addDefaultsIfNotSet()
252 ->children()
253 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['subject'])->end()
254 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['html'])->end()
255 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover']['mail']['text'])->end()
256 ->arrayNode('context')
257 ->treatNullLike(array())
258 ->defaultValue($defaults['recover']['mail']['context'])
259 ->variablePrototype()->end()
260 ->end()
261 ->end()
262 ->end()
263 ->end()
264 ->end()
265 ->arrayNode('recover_mail')
266 ->addDefaultsIfNotSet()
267 ->children()
268 ->arrayNode('route')
269 ->treatNullLike(array())
270 ->defaultValue($defaults['recover_mail']['route'])
271 ->scalarPrototype()->end()
272 ->end()
273 ->arrayNode('view')
274 ->addDefaultsIfNotSet()
275 ->children()
276 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['view']['name'])->end()
277 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['view']['form'])->end()
278 ->arrayNode('context')
279 ->treatNullLike(array())
280 ->defaultValue($defaults['recover_mail']['view']['context'])
281 ->variablePrototype()->end()
282 ->end()
283 ->end()
284 ->end()
285 ->arrayNode('mail')
286 ->addDefaultsIfNotSet()
287 ->children()
288 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['mail']['subject'])->end()
289 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['mail']['html'])->end()
290 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['recover_mail']['mail']['text'])->end()
291 ->arrayNode('context')
292 ->treatNullLike(array())
293 ->defaultValue($defaults['recover_mail']['mail']['context'])
294 ->variablePrototype()->end()
295 ->end()
296 ->end()
297 ->end()
298 ->end()
299 ->end()
300 ->arrayNode('register')
301 ->addDefaultsIfNotSet()
302 ->children()
303 ->arrayNode('route')
304 ->treatNullLike(array())
305 ->defaultValue($defaults['register']['route'])
306 ->scalarPrototype()->end()
307 ->end()
308 ->arrayNode('view')
309 ->addDefaultsIfNotSet()
310 ->children()
311 ->scalarNode('form')->cannotBeEmpty()->defaultValue($defaults['register']['view']['form'])->end()
312 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['register']['view']['name'])->end()
313 ->arrayNode('context')
314 ->treatNullLike(array())
315 ->defaultValue($defaults['register']['view']['context'])
316 ->variablePrototype()->end()
317 ->end()
318 ->end()
319 ->end()
320 ->arrayNode('mail')
321 ->addDefaultsIfNotSet()
322 ->children()
323 ->scalarNode('subject')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['subject'])->end()
324 ->scalarNode('html')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['html'])->end()
325 ->scalarNode('text')->cannotBeEmpty()->defaultValue($defaults['register']['mail']['text'])->end()
326 ->arrayNode('context')
327 ->treatNullLike(array())
328 ->defaultValue($defaults['register']['mail']['context'])
329 ->variablePrototype()->end()
330 ->end()
331 ->end()
332 ->end()
333 ->end()
334 ->end()
335 ->end()
336 ->end();
337
338 return $treeBuilder;
339 }
340 }