|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Silverback API Component 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\ApiComponentBundle\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_component'); |
|
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 |
|
->end(); |
|
34
|
|
|
|
|
35
|
1 |
|
$this->addPublishableNode($rootNode); |
|
36
|
1 |
|
$this->addSecurityNode($rootNode); |
|
37
|
1 |
|
$this->addEnabledComponentsNode($rootNode); |
|
38
|
1 |
|
$this->addUserNode($rootNode); |
|
39
|
|
|
|
|
40
|
1 |
|
return $treeBuilder; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
1 |
|
private function addPublishableNode(ArrayNodeDefinition $rootNode): void |
|
44
|
|
|
{ |
|
45
|
|
|
$rootNode |
|
46
|
1 |
|
->children() |
|
47
|
1 |
|
->arrayNode('publishable') |
|
48
|
1 |
|
->addDefaultsIfNotSet() |
|
49
|
1 |
|
->children() |
|
50
|
1 |
|
->scalarNode('permission') |
|
51
|
1 |
|
->cannotBeEmpty() |
|
52
|
1 |
|
->isRequired() |
|
53
|
1 |
|
->end() |
|
54
|
1 |
|
->end() |
|
|
|
|
|
|
55
|
1 |
|
->end() |
|
56
|
1 |
|
->end(); |
|
57
|
1 |
|
} |
|
58
|
|
|
|
|
59
|
1 |
|
private function addSecurityNode(ArrayNodeDefinition $rootNode): void |
|
60
|
|
|
{ |
|
61
|
|
|
$rootNode |
|
62
|
1 |
|
->children() |
|
63
|
1 |
|
->arrayNode('security') |
|
64
|
1 |
|
->addDefaultsIfNotSet() |
|
65
|
1 |
|
->children() |
|
66
|
1 |
|
->arrayNode('tokens') |
|
67
|
1 |
|
->prototype('scalar')->end() |
|
68
|
1 |
|
->end() |
|
69
|
1 |
|
->end() |
|
70
|
1 |
|
->end() |
|
71
|
1 |
|
->end(); |
|
72
|
1 |
|
} |
|
73
|
|
|
|
|
74
|
1 |
|
private function addEnabledComponentsNode(ArrayNodeDefinition $rootNode): void |
|
75
|
|
|
{ |
|
76
|
|
|
$rootNode |
|
77
|
1 |
|
->children() |
|
78
|
1 |
|
->arrayNode('enabled_components') |
|
79
|
1 |
|
->addDefaultsIfNotSet() |
|
80
|
1 |
|
->children() |
|
81
|
1 |
|
->booleanNode('form')->defaultValue(true)->end() |
|
82
|
1 |
|
->booleanNode('collection')->defaultValue(true)->end() |
|
|
|
|
|
|
83
|
1 |
|
->end() |
|
84
|
1 |
|
->end() |
|
85
|
1 |
|
->end(); |
|
86
|
1 |
|
} |
|
87
|
|
|
|
|
88
|
1 |
|
private function addUserNode(ArrayNodeDefinition $rootNode): void |
|
89
|
|
|
{ |
|
90
|
|
|
$rootNode |
|
91
|
1 |
|
->children() |
|
92
|
1 |
|
->arrayNode('user') |
|
93
|
1 |
|
->addDefaultsIfNotSet() |
|
94
|
1 |
|
->children() |
|
95
|
1 |
|
->scalarNode('class_name')->isRequired()->end() |
|
96
|
1 |
|
->arrayNode('email_verification') |
|
|
|
|
|
|
97
|
1 |
|
->canBeDisabled() |
|
98
|
1 |
|
->addDefaultsIfNotSet() |
|
99
|
1 |
|
->children() |
|
100
|
1 |
|
->arrayNode('email') |
|
101
|
1 |
|
->children() |
|
102
|
1 |
|
->scalarNode('redirect_path_query')->end() |
|
103
|
1 |
|
->scalarNode('default_redirect_path')->isRequired()->end() |
|
104
|
1 |
|
->scalarNode('subject')->cannotBeEmpty()->defaultValue('Please verify your email')->end() |
|
105
|
1 |
|
->end() |
|
106
|
1 |
|
->end() |
|
107
|
1 |
|
->booleanNode('default_value')->isRequired()->end() |
|
108
|
1 |
|
->booleanNode('verify_on_change')->isRequired()->end() |
|
109
|
1 |
|
->booleanNode('verify_on_register')->isRequired()->end() |
|
110
|
1 |
|
->booleanNode('deny_unverified_login')->isRequired()->end() |
|
111
|
1 |
|
->end() |
|
112
|
1 |
|
->end() |
|
113
|
1 |
|
->arrayNode('password_reset') |
|
114
|
1 |
|
->addDefaultsIfNotSet() |
|
115
|
1 |
|
->children() |
|
116
|
1 |
|
->arrayNode('email') |
|
117
|
1 |
|
->children() |
|
118
|
1 |
|
->scalarNode('redirect_path_query')->end() |
|
119
|
1 |
|
->scalarNode('default_redirect_path')->isRequired()->end() |
|
120
|
1 |
|
->scalarNode('subject')->cannotBeEmpty()->defaultValue('Your password has been reset')->end() |
|
121
|
1 |
|
->end() |
|
122
|
1 |
|
->end() |
|
123
|
1 |
|
->integerNode('repeat_ttl_seconds')->defaultValue(8600)->end() |
|
124
|
1 |
|
->integerNode('request_timeout_seconds')->defaultValue(3600)->end() |
|
125
|
1 |
|
->end() |
|
126
|
1 |
|
->end() |
|
127
|
1 |
|
->arrayNode('emails') |
|
128
|
1 |
|
->addDefaultsIfNotSet() |
|
129
|
1 |
|
->children() |
|
130
|
1 |
|
->arrayNode('welcome') |
|
131
|
1 |
|
->canBeDisabled() |
|
132
|
1 |
|
->addDefaultsIfNotSet() |
|
133
|
1 |
|
->children() |
|
134
|
1 |
|
->scalarNode('subject')->cannotBeEmpty()->defaultValue('Welcome to {{ website_name }}')->end() |
|
135
|
1 |
|
->end() |
|
136
|
1 |
|
->end() |
|
137
|
1 |
|
->arrayNode('user_enabled') |
|
138
|
1 |
|
->canBeDisabled() |
|
139
|
1 |
|
->addDefaultsIfNotSet() |
|
140
|
1 |
|
->children() |
|
141
|
1 |
|
->scalarNode('subject')->cannotBeEmpty()->defaultValue('Your account has been enabled')->end() |
|
142
|
1 |
|
->end() |
|
143
|
1 |
|
->end() |
|
144
|
1 |
|
->arrayNode('username_changed') |
|
145
|
1 |
|
->canBeDisabled() |
|
146
|
1 |
|
->addDefaultsIfNotSet() |
|
147
|
1 |
|
->children() |
|
148
|
1 |
|
->scalarNode('subject')->cannotBeEmpty()->defaultValue('Your username has been updated')->end() |
|
149
|
1 |
|
->end() |
|
150
|
1 |
|
->end() |
|
151
|
1 |
|
->arrayNode('password_changed') |
|
152
|
1 |
|
->canBeDisabled() |
|
153
|
1 |
|
->addDefaultsIfNotSet() |
|
154
|
1 |
|
->children() |
|
155
|
1 |
|
->scalarNode('subject')->cannotBeEmpty()->defaultValue('Your password has been changed')->end() |
|
156
|
1 |
|
->end() |
|
157
|
1 |
|
->end() |
|
158
|
1 |
|
->end() |
|
159
|
1 |
|
->end() |
|
160
|
1 |
|
->end() |
|
161
|
1 |
|
->end() |
|
162
|
1 |
|
->end(); |
|
163
|
1 |
|
} |
|
164
|
|
|
} |
|
165
|
|
|
|