GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#73)
by
unknown
14:32
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
ccs 16
cts 16
cp 1
cc 2
nc 2
nop 0
crap 2
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
        $rootNode = $treeBuilder->getRootNode();
26 4
27 4
        if ($rootNode instanceof ArrayNodeDefinition) {
28 4
            $nodeBuilder = $this->generateScopeBaseNode($rootNode);
29 4
            $this->addCaptchaSection($nodeBuilder);
30 4
            $this->addActionsSection($nodeBuilder);
31 4
            $this->addActionConfigSection($nodeBuilder);
32 4
            $this->addExportSection($nodeBuilder);
33
34 4
            $nodeBuilder->end();
35 4
        }
36 4
37 4
        return $treeBuilder;
38 4
    }
39 4
40 4
    private function addCaptchaSection(NodeBuilder $nodeBuilder)
41 4
    {
42
        $nodeBuilder
43 4
            ->arrayNode('captcha')
44 4
                ->addDefaultsIfNotSet()
45
                ->children()
46 4
                    ->booleanNode('enabled')
47 4
                    ->defaultFalse()
48 4
                ->end()
49 4
                ->arrayNode('override_by_type')
50 4
                    ->prototype('array')
51 4
                        ->children()
52 4
                            ->booleanNode('enabled')->defaultFalse()->end()
53 4
                            ->scalarNode('secret')->cannotBeEmpty()->end()
54 4
                            ->scalarNode('site_key')->cannotBeEmpty()->end()
55 4
                            ->arrayNode('options')
56 4
                                ->children()
57 4
                                    ->scalarNode('action')->cannotBeEmpty()->info('This only available in Captcha V3')->end()
58 4
                                    ->enumNode('type')
59 4
                                        ->values(['invisible', 'checkbox'])
60 4
                                        ->defaultValue('checkbox')
61 4
                                        ->cannotBeEmpty()
62 4
                                    ->end()
63 4
                                    ->enumNode('theme')
64 4
                                        ->values(['dark', 'light'])
65 4
                                        ->defaultValue('light')
66 4
                                        ->cannotBeEmpty()
67 4
                                    ->end()
68 4
                                    ->enumNode('size')
69 4
                                        ->values(['normal', 'compact'])
70 4
                                        ->defaultValue('normal')
71 4
                                        ->info('It is only taken into account if you are using the V2 with checkbox option')
72 4
                                        ->cannotBeEmpty()
73 4
                                    ->end()
74 4
                                ->end()
75 4
                            ->end()
76 4
                        ->end()
77 4
                    ->end()
78 4
                ->end()
79 4
                ->scalarNode('secret')
80 4
                    ->isRequired()
81 4
                ->end()
82 4
                ->scalarNode('site_key')
83 4
                    ->isRequired()
84 4
                ->end()
85 4
                ->arrayNode('options')
86
                    ->children()
87 4
                        ->scalarNode('action')->cannotBeEmpty()->info('This only available in Captcha V3')->end()
88
                        ->enumNode('type')
89
                            ->values(['invisible', 'checkbox'])
90
                            ->defaultValue('checkbox')
91
                            ->cannotBeEmpty()
92
                        ->end()
93
                        ->enumNode('theme')
94
                            ->values(['dark', 'light'])
95
                            ->defaultValue('light')
96
                            ->cannotBeEmpty()
97
                        ->end()
98
                        ->enumNode('size')
99
                            ->values(['normal', 'compact'])
100
                            ->defaultValue('normal')
101
                            ->info('It is only taken into account if you are using the V2 with checkbox option')
102
                            ->cannotBeEmpty()
103
                        ->end()
104
                    ->end()
105
                ->end()
106
            ->end()
107
            ->end();
108
    }
109
110
    private function addActionsSection(NodeBuilder $nodeBuilder)
111
    {
112
        $nodeBuilder
113
            ->arrayNode(ConfigurationConstants::ACTIONS)
114
                ->isRequired()
115
                ->normalizeKeys(false)
116
                    ->children()
117
                        ->arrayNode(ConfigurationConstants::SETTINGS_DEFAULT)
118
                            ->isRequired()
119
                            ->prototype('scalar')
120
                                ->isRequired()
121
                                ->cannotBeEmpty()
122
                            ->end()
123
                        ->end()
124
                        ->arrayNode(ConfigurationConstants::CONTENT_TYPES)
125
                            ->prototype('array')
126
                            ->prototype('scalar')
127
                                ->isRequired()
128
                                ->cannotBeEmpty()
129
                        ->end()
130
                    ->end()
131
                ->end()
132
            ->end()
133
        ->end();
134
    }
135
136
    private function addActionConfigSection(NodeBuilder $nodeBuilder)
137
    {
138
        $nodeBuilder
139
            ->arrayNode(ConfigurationConstants::ACTION_CONFIG)
140
                ->isRequired()
141
                ->normalizeKeys(false)
142
                    ->children()
143
                        ->arrayNode(ConfigurationConstants::ACTION_AUTO_RESPONDER)
144
                            ->addDefaultsIfNotSet()
145
                                ->children()
146
                                    ->arrayNode(ConfigurationConstants::TEMPLATES)
147
                                        ->children()
148
                                            ->scalarNode(ConfigurationConstants::SETTINGS_DEFAULT)
149
                                                ->isRequired()
150
                                                ->cannotBeEmpty()
151
                                            ->end()
152
                                            ->arrayNode(ConfigurationConstants::CONTENT_TYPES)
153
                                                ->prototype('scalar')
154
                                                    ->isRequired()
155
                                                    ->cannotBeEmpty()
156
                                                ->end()
157
                                            ->end()
158
                                        ->end()
159
                                    ->end()
160
                                    ->arrayNode(ConfigurationConstants::DEFAULT_VARIABLES)
161
                                        ->children()
162
                                            ->scalarNode(ConfigurationConstants::EMAIL_SENDER)
163
                                                ->isRequired()
164
                                                ->cannotBeEmpty()
165
                                            ->end()
166
                                            ->scalarNode(ConfigurationConstants::EMAIL_SUBJECT)
167
                                                ->isRequired()
168
                                                ->cannotBeEmpty()
169
                                            ->end()
170
                                            ->scalarNode(ConfigurationConstants::EMAIL_FIELD_IDENTIFIER)
171
                                                ->defaultValue(ConfigurationConstants::ACTION_EMAIL)
172
                                                ->cannotBeEmpty()
173
                                            ->end()
174
                                        ->end()
175
                                    ->end()
176
                                ->end()
177
                            ->end()
178
                        ->arrayNode('email')
179
                            ->children()
180
                                ->arrayNode(ConfigurationConstants::TEMPLATES)
181
                                    ->children()
182
                                        ->scalarNode(ConfigurationConstants::SETTINGS_DEFAULT)
183
                                            ->isRequired()
184
                                            ->cannotBeEmpty()
185
                                        ->end()
186
                                        ->arrayNode(ConfigurationConstants::CONTENT_TYPES)
187
                                            ->prototype('scalar')
188
                                                ->isRequired()
189
                                                ->cannotBeEmpty()
190
                                            ->end()
191
                                        ->end()
192
                                    ->end()
193
                                ->end()
194
                                ->arrayNode(ConfigurationConstants::ATTACHMENTS)
195
                                    ->children()
196
                                        ->scalarNode('enabled')
197
                                            ->isRequired()
198
                                            ->defaultValue(true)
199
                                        ->end()
200
                                        ->arrayNode(ConfigurationConstants::CONTENT_TYPES)
201
                                            ->prototype('scalar')
202
                                                ->isRequired()
203
                                                ->cannotBeEmpty()
204
                                            ->end()
205
                                        ->end()
206
                                    ->end()
207
                                ->end()
208
                                ->arrayNode(ConfigurationConstants::DEFAULT_VARIABLES)
209
                                    ->children()
210
                                        ->scalarNode(ConfigurationConstants::EMAIL_SENDER)
211
                                            ->isRequired()
212
                                            ->cannotBeEmpty()
213
                                        ->end()
214
                                        ->scalarNode(ConfigurationConstants::EMAIL_RECIPIENT)
215
                                            ->isRequired()
216
                                            ->cannotBeEmpty()
217
                                        ->end()
218
                                        ->scalarNode(ConfigurationConstants::EMAIL_SUBJECT)
219
                                            ->cannotBeEmpty()
220
                                        ->end()
221
                                    ->end()
222
                                ->end()
223
                            ->end()
224
                        ->end()
225
                    ->end()
226
            ->end();
227
    }
228
229
    private function addExportSection(NodeBuilder $nodeBuilder)
230
    {
231
        $nodeBuilder
232
            ->arrayNode('export')
233
                ->addDefaultsIfNotSet()
234
                ->children()
235
                    ->arrayNode('csv')
236
                        ->addDefaultsIfNotSet()
237
                        ->children()
238
                            ->scalarNode('delimiter')->defaultValue(',')->end()
239
                            // by default use windows line endings for compatibility with some csv libraries
240
                            ->scalarNode('newline')->defaultValue("\r\n")->end()
241
                            ->scalarNode('enclosure')->defaultValue("\"")->end()
242
                        ->end()
243
                    ->end()
244
                ->end()
245
            ->end();
246
    }
247
}
248