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