]> Raphaƫl G. Git Repositories - userbundle/blob - DependencyInjection/Configuration.php
b02524c48424c4de44d61c17f3925dd513b434e9
[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 'contact' => [
29 'name' => 'John Doe',
30 'mail' => 'contact@example.com',
31 'home_name' => 'rapsys_user_homepage',
32 'home_args' => []
33 ],
34 'login' => [
35 'template' => '@@RapsysUser/security/login.html.twig',
36 'context' => []
37 ],
38 'register' => [
39 'mail_template' => '@@RapsysUser/mail/register.html.twig',
40 'mail_context' => [
41 'title' => 'Title',
42 'subtitle' => 'Hi, %%name%%',
43 'subject' => 'Welcome to %%title%%',
44 'message' => 'Thanks so much for joining us, from now on, you are part of %%title%%.'
45 ],
46 'template' => '@@RapsysUser/security/register.html.twig',
47 'context' => []
48 ],
49 'recover' => [
50 'mail_template' => '@@RapsysUser/mail/recover.html.twig',
51 'mail_context' => [
52 'title' => 'Title',
53 'subtitle' => 'Hi, %%name%%',
54 'subject' => 'Recover account on %%title%%',
55 'raw' => 'Thanks so much for joining us, to recover your account you can follow this link: <a href="%%url%%">%%url%%</a>'
56 ],
57 'url_name' => 'rapsys_user_recover_mail',
58 'url_args' => [],
59 'template' => '@@RapsysUser/security/recover.html.twig',
60 'context' => []
61 ],
62 'recover_mail' => [
63 'mail_template' => '@@RapsysUser/mail/recover.html.twig',
64 'mail_context' => [
65 'title' => 'Title',
66 'subtitle' => 'Hi, %%name%%',
67 'subject' => 'Account recovered on %%title%%',
68 'raw' => 'Your account password has been changed, to recover your account you can follow this link: <a href="%%url%%">%%url%%</a>'
69 ],
70 'url_name' => 'rapsys_user_recover_mail',
71 'url_args' => [],
72 'template' => '@@RapsysUser/security/recover_mail.html.twig',
73 'context' => []
74 ]
75 ];
76
77 //Here we define the parameters that are allowed to configure the bundle.
78 //TODO: see https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php for default value and description
79 //TODO: see http://symfony.com/doc/current/components/config/definition.html
80 //TODO: see fosuser DependencyInjection/Configuration.php
81 //XXX: use bin/console config:dump-reference to dump class infos
82
83 //Here we define the parameters that are allowed to configure the bundle.
84 $treeBuilder
85 //Parameters
86 ->getRootNode()
87 ->addDefaultsIfNotSet()
88 ->children()
89 ->arrayNode('class')
90 ->addDefaultsIfNotSet()
91 ->children()
92 ->scalarNode('group')->cannotBeEmpty()->defaultValue($defaults['class']['group'])->end()
93 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['class']['title'])->end()
94 ->scalarNode('user')->cannotBeEmpty()->defaultValue($defaults['class']['user'])->end()
95 ->end()
96 ->end()
97 ->arrayNode('contact')
98 ->addDefaultsIfNotSet()
99 ->children()
100 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['contact']['name'])->end()
101 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
102 ->scalarNode('home_name')->cannotBeEmpty()->defaultValue($defaults['contact']['home_name'])->end()
103 ->arrayNode('home_args')
104 ->cannotBeEmpty()
105 ->treatNullLike($defaults['contact']['home_args'])
106 ->defaultValue($defaults['contact']['home_args'])
107 ->scalarPrototype()->end()
108 ->end()
109 ->end()
110 ->end()
111 ->arrayNode('login')
112 ->addDefaultsIfNotSet()
113 ->children()
114 ->scalarNode('template')->cannotBeEmpty()->defaultValue($defaults['login']['template'])->end()
115 ->arrayNode('context')
116 ->cannotBeEmpty()
117 ->treatNullLike(array())
118 ->defaultValue($defaults['login']['context'])
119 ->scalarPrototype()->end()
120 ->end()
121 ->end()
122 ->end()
123 ->arrayNode('register')
124 ->addDefaultsIfNotSet()
125 ->children()
126 ->scalarNode('mail_template')->cannotBeEmpty()->defaultValue($defaults['register']['mail_template'])->end()
127 ->arrayNode('mail_context')
128 ->cannotBeEmpty()
129 ->treatNullLike($defaults['register']['mail_context'])
130 ->defaultValue($defaults['register']['mail_context'])
131 ->scalarPrototype()->end()
132 ->end()
133 ->scalarNode('template')->cannotBeEmpty()->defaultValue($defaults['register']['template'])->end()
134 ->arrayNode('context')
135 ->cannotBeEmpty()
136 ->treatNullLike($defaults['register']['context'])
137 ->defaultValue($defaults['register']['context'])
138 ->scalarPrototype()->end()
139 ->end()
140 ->end()
141 ->end()
142 ->arrayNode('recover')
143 ->addDefaultsIfNotSet()
144 ->children()
145 ->scalarNode('mail_template')->cannotBeEmpty()->defaultValue($defaults['recover']['mail_template'])->end()
146 ->arrayNode('mail_context')
147 ->cannotBeEmpty()
148 ->treatNullLike($defaults['recover']['mail_context'])
149 ->defaultValue($defaults['recover']['mail_context'])
150 ->scalarPrototype()->end()
151 ->end()
152 ->scalarNode('url_name')->cannotBeEmpty()->defaultValue($defaults['recover']['url_name'])->end()
153 ->arrayNode('url_args')
154 ->cannotBeEmpty()
155 ->treatNullLike($defaults['recover']['url_args'])
156 ->defaultValue($defaults['recover']['url_args'])
157 ->scalarPrototype()->end()
158 ->end()
159 ->scalarNode('template')->cannotBeEmpty()->defaultValue($defaults['recover']['template'])->end()
160 ->arrayNode('context')
161 ->cannotBeEmpty()
162 ->treatNullLike(array())
163 ->defaultValue($defaults['recover']['context'])
164 ->scalarPrototype()->end()
165 ->end()
166 ->end()
167 ->end()
168 ->arrayNode('recover_mail')
169 ->addDefaultsIfNotSet()
170 ->children()
171 ->scalarNode('mail_template')->cannotBeEmpty()->defaultValue($defaults['recover']['mail_template'])->end()
172 ->arrayNode('mail_context')
173 ->cannotBeEmpty()
174 ->treatNullLike($defaults['recover']['mail_context'])
175 ->defaultValue($defaults['recover']['mail_context'])
176 ->scalarPrototype()->end()
177 ->end()
178 ->scalarNode('url_name')->cannotBeEmpty()->defaultValue($defaults['recover']['url_name'])->end()
179 ->arrayNode('url_args')
180 ->cannotBeEmpty()
181 ->treatNullLike($defaults['recover']['url_args'])
182 ->defaultValue($defaults['recover']['url_args'])
183 ->scalarPrototype()->end()
184 ->end()
185 ->scalarNode('template')->cannotBeEmpty()->defaultValue($defaults['recover']['template'])->end()
186 ->arrayNode('context')
187 ->cannotBeEmpty()
188 ->treatNullLike(array())
189 ->defaultValue($defaults['recover']['context'])
190 ->scalarPrototype()->end()
191 ->end()
192 ->end()
193 ->end()
194 ->end()
195 ->end();
196
197 return $treeBuilder;
198 }
199 }