|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Silverback API Components Bundle Project |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Daniel West <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace Silverback\ApiComponentsBundle\DependencyInjection; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
|
17
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
18
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @author Daniel West <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class Configuration implements ConfigurationInterface |
|
24
|
|
|
{ |
|
25
|
1 |
|
public function getConfigTreeBuilder(): TreeBuilder |
|
26
|
|
|
{ |
|
27
|
1 |
|
$treeBuilder = new TreeBuilder('silverback_api_components'); |
|
28
|
1 |
|
$rootNode = $treeBuilder->getRootNode(); |
|
29
|
|
|
$rootNode |
|
30
|
1 |
|
->children() |
|
31
|
1 |
|
->scalarNode('website_name')->isRequired()->end() |
|
32
|
1 |
|
->scalarNode('table_prefix')->defaultValue('_acb_')->end() |
|
33
|
1 |
|
->scalarNode('metadata_key')->defaultValue('_metadata')->end() |
|
34
|
1 |
|
->end(); |
|
35
|
|
|
|
|
36
|
1 |
|
$this->addRouteSecurityNode($rootNode); |
|
37
|
1 |
|
$this->addRefreshTokenNode($rootNode); |
|
38
|
1 |
|
$this->addPublishableNode($rootNode); |
|
39
|
1 |
|
$this->addEnabledComponentsNode($rootNode); |
|
40
|
1 |
|
$this->addUserNode($rootNode); |
|
41
|
|
|
|
|
42
|
1 |
|
return $treeBuilder; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
1 |
|
private function addRouteSecurityNode(ArrayNodeDefinition $rootNode): void |
|
46
|
|
|
{ |
|
47
|
|
|
$rootNode |
|
48
|
1 |
|
->children() |
|
49
|
1 |
|
->arrayNode('route_security') |
|
50
|
1 |
|
->arrayPrototype() |
|
51
|
1 |
|
->children() |
|
52
|
1 |
|
->scalarNode('route')->end() |
|
53
|
1 |
|
->scalarNode('security')->end() |
|
|
|
|
|
|
54
|
1 |
|
->end() |
|
55
|
1 |
|
->end() |
|
56
|
1 |
|
->end() |
|
57
|
1 |
|
->end(); |
|
58
|
1 |
|
} |
|
59
|
|
|
|
|
60
|
1 |
|
private function addRefreshTokenNode(ArrayNodeDefinition $rootNode): void |
|
61
|
|
|
{ |
|
62
|
|
|
$rootNode |
|
63
|
1 |
|
->children() |
|
64
|
1 |
|
->arrayNode('refresh_token') |
|
65
|
1 |
|
->addDefaultsIfNotSet() |
|
66
|
1 |
|
->children() |
|
67
|
1 |
|
->scalarNode('handler_id')->cannotBeEmpty()->isRequired()->end() |
|
68
|
1 |
|
->arrayNode('options') |
|
|
|
|
|
|
69
|
1 |
|
->useAttributeAsKey('key') |
|
70
|
1 |
|
->prototype('variable')->end() |
|
71
|
1 |
|
->end() |
|
72
|
1 |
|
->scalarNode('cookie_name')->cannotBeEmpty()->isRequired()->end() |
|
73
|
1 |
|
->scalarNode('ttl')->cannotBeEmpty()->isRequired()->end() |
|
74
|
1 |
|
->scalarNode('database_user_provider')->cannotBeEmpty()->isRequired()->end() |
|
75
|
1 |
|
->end() |
|
76
|
1 |
|
->end() |
|
77
|
1 |
|
->end(); |
|
78
|
1 |
|
} |
|
79
|
|
|
|
|
80
|
1 |
|
private function addPublishableNode(ArrayNodeDefinition $rootNode): void |
|
81
|
|
|
{ |
|
82
|
|
|
$rootNode |
|
83
|
1 |
|
->children() |
|
84
|
1 |
|
->arrayNode('publishable') |
|
85
|
1 |
|
->addDefaultsIfNotSet() |
|
86
|
1 |
|
->children() |
|
87
|
1 |
|
->scalarNode('permission')->cannotBeEmpty()->isRequired()->end() |
|
88
|
1 |
|
->end() |
|
|
|
|
|
|
89
|
1 |
|
->end() |
|
90
|
1 |
|
->end(); |
|
91
|
1 |
|
} |
|
92
|
|
|
|
|
93
|
1 |
|
private function addEnabledComponentsNode(ArrayNodeDefinition $rootNode): void |
|
94
|
|
|
{ |
|
95
|
|
|
$rootNode |
|
96
|
1 |
|
->children() |
|
97
|
1 |
|
->arrayNode('enabled_components') |
|
98
|
1 |
|
->addDefaultsIfNotSet() |
|
99
|
1 |
|
->children() |
|
100
|
1 |
|
->booleanNode('form')->defaultValue(true)->end() |
|
101
|
1 |
|
->booleanNode('collection')->defaultValue(true)->end() |
|
|
|
|
|
|
102
|
1 |
|
->end() |
|
103
|
1 |
|
->end() |
|
104
|
1 |
|
->end(); |
|
105
|
1 |
|
} |
|
106
|
|
|
|
|
107
|
1 |
|
private function addUserNode(ArrayNodeDefinition $rootNode): void |
|
108
|
|
|
{ |
|
109
|
|
|
$rootNode |
|
110
|
1 |
|
->children() |
|
111
|
1 |
|
->arrayNode('user') |
|
112
|
1 |
|
->addDefaultsIfNotSet() |
|
113
|
1 |
|
->children() |
|
114
|
1 |
|
->scalarNode('class_name') |
|
115
|
1 |
|
->isRequired() |
|
116
|
1 |
|
->end() |
|
117
|
1 |
|
->arrayNode('email_verification') |
|
118
|
1 |
|
->canBeDisabled() |
|
119
|
1 |
|
->addDefaultsIfNotSet() |
|
120
|
1 |
|
->children() |
|
121
|
1 |
|
->arrayNode('email') |
|
122
|
1 |
|
->children() |
|
123
|
1 |
|
->scalarNode('redirect_path_query')->end() |
|
124
|
1 |
|
->scalarNode('default_redirect_path')->isRequired()->end() |
|
125
|
1 |
|
->scalarNode('subject')->cannotBeEmpty()->defaultValue('Please verify your email')->end() |
|
126
|
1 |
|
->end() |
|
127
|
1 |
|
->end() |
|
128
|
1 |
|
->booleanNode('default_value')->isRequired()->end() |
|
129
|
1 |
|
->booleanNode('verify_on_change')->isRequired()->end() |
|
130
|
1 |
|
->booleanNode('verify_on_register')->isRequired()->end() |
|
131
|
1 |
|
->booleanNode('deny_unverified_login')->isRequired()->end() |
|
132
|
1 |
|
->end() |
|
133
|
1 |
|
->end() |
|
134
|
1 |
|
->arrayNode('new_email_confirmation') |
|
135
|
1 |
|
->addDefaultsIfNotSet() |
|
136
|
1 |
|
->children() |
|
137
|
1 |
|
->arrayNode('email') |
|
138
|
1 |
|
->children() |
|
139
|
1 |
|
->scalarNode('redirect_path_query')->end() |
|
140
|
1 |
|
->scalarNode('default_redirect_path')->isRequired()->end() |
|
141
|
1 |
|
->scalarNode('subject')->cannotBeEmpty()->defaultValue('Please confirm your new email address')->end() |
|
142
|
1 |
|
->end() |
|
143
|
1 |
|
->end() |
|
144
|
1 |
|
->integerNode('request_timeout_seconds')->defaultValue(86400)->end() |
|
145
|
1 |
|
->end() |
|
146
|
1 |
|
->end() |
|
147
|
1 |
|
->arrayNode('password_reset') |
|
148
|
1 |
|
->addDefaultsIfNotSet() |
|
149
|
1 |
|
->children() |
|
150
|
1 |
|
->arrayNode('email') |
|
151
|
1 |
|
->children() |
|
152
|
1 |
|
->scalarNode('redirect_path_query')->end() |
|
153
|
1 |
|
->scalarNode('default_redirect_path')->isRequired()->end() |
|
154
|
1 |
|
->scalarNode('subject')->cannotBeEmpty()->defaultValue('Your password has been reset')->end() |
|
155
|
1 |
|
->end() |
|
156
|
1 |
|
->end() |
|
157
|
1 |
|
->integerNode('repeat_ttl_seconds')->defaultValue(8600)->end() |
|
158
|
1 |
|
->integerNode('request_timeout_seconds')->defaultValue(3600)->end() |
|
159
|
1 |
|
->end() |
|
160
|
1 |
|
->end() |
|
161
|
1 |
|
->arrayNode('emails') |
|
162
|
1 |
|
->addDefaultsIfNotSet() |
|
163
|
1 |
|
->children() |
|
164
|
1 |
|
->arrayNode('welcome') |
|
165
|
1 |
|
->canBeDisabled() |
|
166
|
1 |
|
->addDefaultsIfNotSet() |
|
167
|
1 |
|
->children() |
|
168
|
1 |
|
->scalarNode('subject')->cannotBeEmpty()->defaultValue('Welcome to {{ website_name }}')->end() |
|
169
|
1 |
|
->end() |
|
170
|
1 |
|
->end() |
|
171
|
1 |
|
->arrayNode('user_enabled') |
|
172
|
1 |
|
->canBeDisabled() |
|
173
|
1 |
|
->addDefaultsIfNotSet() |
|
174
|
1 |
|
->children() |
|
175
|
1 |
|
->scalarNode('subject')->cannotBeEmpty()->defaultValue('Your account has been enabled')->end() |
|
176
|
1 |
|
->end() |
|
177
|
1 |
|
->end() |
|
178
|
1 |
|
->arrayNode('username_changed') |
|
179
|
1 |
|
->canBeDisabled() |
|
180
|
1 |
|
->addDefaultsIfNotSet() |
|
181
|
1 |
|
->children() |
|
182
|
1 |
|
->scalarNode('subject')->cannotBeEmpty()->defaultValue('Your username has been updated')->end() |
|
183
|
1 |
|
->end() |
|
184
|
1 |
|
->end() |
|
185
|
1 |
|
->arrayNode('password_changed') |
|
186
|
1 |
|
->canBeDisabled() |
|
187
|
1 |
|
->addDefaultsIfNotSet() |
|
188
|
1 |
|
->children() |
|
189
|
1 |
|
->scalarNode('subject')->cannotBeEmpty()->defaultValue('Your password has been changed')->end() |
|
190
|
1 |
|
->end() |
|
191
|
1 |
|
->end() |
|
192
|
1 |
|
->end() |
|
193
|
1 |
|
->end() |
|
194
|
1 |
|
->end() |
|
195
|
1 |
|
->end() |
|
196
|
1 |
|
->end(); |
|
197
|
1 |
|
} |
|
198
|
|
|
} |
|
199
|
|
|
|