1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Netgen\Bundle\InformationCollectionBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\Configuration as SiteAccessConfiguration; |
6
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
7
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeBuilder; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* This is the class that validates and merges configuration from your app/config files. |
11
|
|
|
* |
12
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} |
13
|
|
|
*/ |
14
|
|
|
class Configuration extends SiteAccessConfiguration |
15
|
|
|
{ |
16
|
4 |
|
/** |
17
|
|
|
* {@inheritdoc} |
18
|
4 |
|
*/ |
19
|
4 |
|
public function getConfigTreeBuilder() |
20
|
|
|
{ |
21
|
4 |
|
$treeBuilder = new TreeBuilder(); |
22
|
4 |
|
$rootNode = $treeBuilder->root(ConfigurationConstants::SETTINGS_ROOT); |
23
|
4 |
|
|
24
|
4 |
|
$nodeBuilder = $this->generateScopeBaseNode($rootNode); |
25
|
4 |
|
$this->addCaptchaSection($nodeBuilder); |
26
|
4 |
|
$this->addActionsSection($nodeBuilder); |
27
|
4 |
|
$this->addActionConfigSection($nodeBuilder); |
28
|
4 |
|
|
29
|
4 |
|
$nodeBuilder->end(); |
30
|
4 |
|
|
31
|
4 |
|
return $treeBuilder; |
32
|
4 |
|
} |
33
|
|
|
|
34
|
4 |
|
private function addCaptchaSection(NodeBuilder $nodeBuilder) |
35
|
4 |
|
{ |
36
|
4 |
|
$nodeBuilder |
37
|
4 |
|
->arrayNode('captcha') |
38
|
4 |
|
->addDefaultsIfNotSet() |
39
|
4 |
|
->children() |
40
|
4 |
|
->booleanNode('enabled') |
41
|
4 |
|
->defaultFalse() |
42
|
|
|
->end() |
43
|
4 |
|
->arrayNode('override_by_type') |
44
|
4 |
|
->prototype('array') |
45
|
|
|
->children() |
46
|
4 |
|
->booleanNode('enabled')->defaultFalse()->end() |
47
|
4 |
|
->scalarNode('secret')->cannotBeEmpty()->end() |
48
|
4 |
|
->scalarNode('site_key')->cannotBeEmpty()->end() |
49
|
4 |
|
->arrayNode('options') |
50
|
4 |
|
->children() |
51
|
4 |
|
->scalarNode('hostname')->cannotBeEmpty()->end() |
52
|
4 |
|
->scalarNode('apk_package_name')->cannotBeEmpty()->end() |
53
|
4 |
|
->scalarNode('action')->cannotBeEmpty()->end() |
54
|
4 |
|
->scalarNode('score_threshold')->cannotBeEmpty()->end() |
55
|
4 |
|
->scalarNode('challenge_timeout')->cannotBeEmpty()->end() |
56
|
4 |
|
->end() |
57
|
4 |
|
->end() |
58
|
4 |
|
->end() |
59
|
4 |
|
->end() |
60
|
4 |
|
->end() |
61
|
4 |
|
->scalarNode('secret') |
62
|
4 |
|
->isRequired() |
63
|
4 |
|
->end() |
64
|
4 |
|
->scalarNode('site_key') |
65
|
4 |
|
->isRequired() |
66
|
4 |
|
->end() |
67
|
4 |
|
->arrayNode('options') |
68
|
4 |
|
->children() |
69
|
4 |
|
->scalarNode('hostname') |
70
|
4 |
|
->cannotBeEmpty() |
71
|
4 |
|
->end() |
72
|
4 |
|
->scalarNode('apk_package_name') |
73
|
4 |
|
->cannotBeEmpty() |
74
|
4 |
|
->end() |
75
|
4 |
|
->scalarNode('action') |
76
|
4 |
|
->cannotBeEmpty() |
77
|
4 |
|
->end() |
78
|
4 |
|
->scalarNode('score_threshold') |
79
|
4 |
|
->cannotBeEmpty() |
80
|
4 |
|
->end() |
81
|
4 |
|
->scalarNode('challenge_timeout') |
82
|
4 |
|
->cannotBeEmpty() |
83
|
4 |
|
->end() |
84
|
4 |
|
->end() |
85
|
4 |
|
->end() |
86
|
|
|
->end() |
87
|
4 |
|
->end(); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
private function addActionsSection(NodeBuilder $nodeBuilder) |
91
|
|
|
{ |
92
|
|
|
$nodeBuilder |
93
|
|
|
->arrayNode(ConfigurationConstants::ACTIONS) |
94
|
|
|
->isRequired() |
95
|
|
|
->normalizeKeys(false) |
96
|
|
|
->children() |
97
|
|
|
->arrayNode(ConfigurationConstants::SETTINGS_DEFAULT) |
98
|
|
|
->isRequired() |
99
|
|
|
->prototype('scalar') |
100
|
|
|
->isRequired() |
101
|
|
|
->cannotBeEmpty() |
102
|
|
|
->end() |
103
|
|
|
->end() |
104
|
|
|
->arrayNode(ConfigurationConstants::CONTENT_TYPES) |
105
|
|
|
->prototype('array') |
106
|
|
|
->prototype('scalar') |
107
|
|
|
->isRequired() |
108
|
|
|
->cannotBeEmpty() |
109
|
|
|
->end() |
110
|
|
|
->end() |
111
|
|
|
->end() |
112
|
|
|
->end() |
113
|
|
|
->end(); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
private function addActionConfigSection(NodeBuilder $nodeBuilder) |
117
|
|
|
{ |
118
|
|
|
$nodeBuilder |
119
|
|
|
->arrayNode(ConfigurationConstants::ACTION_CONFIG) |
120
|
|
|
->isRequired() |
121
|
|
|
->normalizeKeys(false) |
122
|
|
|
->children() |
123
|
|
|
->arrayNode(ConfigurationConstants::ACTION_AUTO_RESPONDER) |
124
|
|
|
->addDefaultsIfNotSet() |
125
|
|
|
->children() |
126
|
|
|
->arrayNode(ConfigurationConstants::TEMPLATES) |
127
|
|
|
->children() |
128
|
|
|
->scalarNode(ConfigurationConstants::SETTINGS_DEFAULT) |
129
|
|
|
->isRequired() |
130
|
|
|
->cannotBeEmpty() |
131
|
|
|
->end() |
132
|
|
|
->arrayNode(ConfigurationConstants::CONTENT_TYPES) |
133
|
|
|
->prototype('scalar') |
134
|
|
|
->isRequired() |
135
|
|
|
->cannotBeEmpty() |
136
|
|
|
->end() |
137
|
|
|
->end() |
138
|
|
|
->end() |
139
|
|
|
->end() |
140
|
|
|
->arrayNode(ConfigurationConstants::DEFAULT_VARIABLES) |
141
|
|
|
->children() |
142
|
|
|
->scalarNode(ConfigurationConstants::EMAIL_SENDER) |
143
|
|
|
->isRequired() |
144
|
|
|
->cannotBeEmpty() |
145
|
|
|
->end() |
146
|
|
|
->scalarNode(ConfigurationConstants::EMAIL_SUBJECT) |
147
|
|
|
->isRequired() |
148
|
|
|
->cannotBeEmpty() |
149
|
|
|
->end() |
150
|
|
|
->scalarNode(ConfigurationConstants::EMAIL_FIELD_IDENTIFIER) |
151
|
|
|
->defaultValue('email') |
152
|
|
|
->cannotBeEmpty() |
153
|
|
|
->end() |
154
|
|
|
->end() |
155
|
|
|
->end() |
156
|
|
|
->end() |
157
|
|
|
->end() |
158
|
|
|
->arrayNode(ConfigurationConstants::ACTION_EMAIL) |
159
|
|
|
->children() |
160
|
|
|
->arrayNode(ConfigurationConstants::TEMPLATES) |
161
|
|
|
->children() |
162
|
|
|
->scalarNode(ConfigurationConstants::SETTINGS_DEFAULT) |
163
|
|
|
->isRequired() |
164
|
|
|
->cannotBeEmpty() |
165
|
|
|
->end() |
166
|
|
|
->arrayNode(ConfigurationConstants::CONTENT_TYPES) |
167
|
|
|
->prototype('scalar') |
168
|
|
|
->isRequired() |
169
|
|
|
->cannotBeEmpty() |
170
|
|
|
->end() |
171
|
|
|
->end() |
172
|
|
|
->end() |
173
|
|
|
->end() |
174
|
|
|
->arrayNode(ConfigurationConstants::ATTACHMENTS) |
175
|
|
|
->children() |
176
|
|
|
->scalarNode(ConfigurationConstants::SETTINGS_DEFAULT) |
177
|
|
|
->isRequired() |
178
|
|
|
->defaultValue(true) |
179
|
|
|
->end() |
180
|
|
|
->arrayNode(ConfigurationConstants::CONTENT_TYPES) |
181
|
|
|
->prototype('scalar') |
182
|
|
|
->isRequired() |
183
|
|
|
->cannotBeEmpty() |
184
|
|
|
->end() |
185
|
|
|
->end() |
186
|
|
|
->end() |
187
|
|
|
->end() |
188
|
|
|
->arrayNode(ConfigurationConstants::DEFAULT_VARIABLES) |
189
|
|
|
->children() |
190
|
|
|
->scalarNode(ConfigurationConstants::EMAIL_SENDER) |
191
|
|
|
->isRequired() |
192
|
|
|
->cannotBeEmpty() |
193
|
|
|
->end() |
194
|
|
|
->scalarNode(ConfigurationConstants::EMAIL_RECIPIENT) |
195
|
|
|
->isRequired() |
196
|
|
|
->cannotBeEmpty() |
197
|
|
|
->end() |
198
|
|
|
->scalarNode(ConfigurationConstants::EMAIL_SUBJECT) |
199
|
|
|
->cannotBeEmpty() |
200
|
|
|
->end() |
201
|
|
|
->end() |
202
|
|
|
->end() |
203
|
|
|
->end() |
204
|
|
|
->end() |
205
|
|
|
->end() |
206
|
|
|
->end(); |
207
|
|
|
} |
208
|
|
|
} |
209
|
|
|
|