|
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
|
|
|
public function getConfigTreeBuilder(): TreeBuilder |
|
26
|
|
|
{ |
|
27
|
|
|
$treeBuilder = new TreeBuilder('silverback_api_component'); |
|
28
|
|
|
$rootNode = $treeBuilder->getRootNode(); |
|
29
|
|
|
$rootNode |
|
30
|
|
|
->children() |
|
31
|
|
|
->scalarNode('website_name')->isRequired()->end() |
|
32
|
|
|
->scalarNode('table_prefix')->defaultValue('_acb_')->end() |
|
33
|
|
|
->end(); |
|
34
|
|
|
|
|
35
|
|
|
$this->addPublishableNode($rootNode); |
|
36
|
|
|
$this->addSecurityNode($rootNode); |
|
37
|
|
|
$this->addEnabledComponentsNode($rootNode); |
|
38
|
|
|
$this->addUserNode($rootNode); |
|
39
|
|
|
|
|
40
|
|
|
return $treeBuilder; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
private function addPublishableNode(ArrayNodeDefinition $rootNode): void |
|
44
|
|
|
{ |
|
45
|
|
|
$rootNode |
|
46
|
|
|
->children() |
|
47
|
|
|
->arrayNode('publishable') |
|
48
|
|
|
->addDefaultsIfNotSet() |
|
49
|
|
|
->children() |
|
50
|
|
|
->scalarNode('permission') |
|
51
|
|
|
->cannotBeEmpty() |
|
52
|
|
|
->defaultValue(sprintf('is_granted(ROLE_ADMIN)')) |
|
53
|
|
|
->end() |
|
54
|
|
|
->end() |
|
|
|
|
|
|
55
|
|
|
->end() |
|
56
|
|
|
->end(); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
private function addSecurityNode(ArrayNodeDefinition $rootNode): void |
|
60
|
|
|
{ |
|
61
|
|
|
$rootNode |
|
62
|
|
|
->children() |
|
63
|
|
|
->arrayNode('security') |
|
64
|
|
|
->addDefaultsIfNotSet() |
|
65
|
|
|
->children() |
|
66
|
|
|
->arrayNode('tokens') |
|
67
|
|
|
->prototype('scalar')->end() |
|
68
|
|
|
->end() |
|
69
|
|
|
->end() |
|
70
|
|
|
->end() |
|
71
|
|
|
->end(); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
private function addEnabledComponentsNode(ArrayNodeDefinition $rootNode): void |
|
75
|
|
|
{ |
|
76
|
|
|
$rootNode |
|
77
|
|
|
->children() |
|
78
|
|
|
->arrayNode('enabled_components') |
|
79
|
|
|
->addDefaultsIfNotSet() |
|
80
|
|
|
->children() |
|
81
|
|
|
->booleanNode('form')->defaultValue(true)->end() |
|
82
|
|
|
->booleanNode('collection')->defaultValue(true)->end() |
|
|
|
|
|
|
83
|
|
|
->end() |
|
84
|
|
|
->end() |
|
85
|
|
|
->end(); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
private function addUserNode(ArrayNodeDefinition $rootNode): void |
|
89
|
|
|
{ |
|
90
|
|
|
$rootNode |
|
91
|
|
|
->children() |
|
92
|
|
|
->arrayNode('user') |
|
93
|
|
|
->addDefaultsIfNotSet() |
|
94
|
|
|
->children() |
|
95
|
|
|
->scalarNode('class_name')->isRequired()->end() |
|
96
|
|
|
->arrayNode('email_verification') |
|
|
|
|
|
|
97
|
|
|
->addDefaultsIfNotSet() |
|
98
|
|
|
->children() |
|
99
|
|
|
->booleanNode('default')->isRequired()->end() |
|
100
|
|
|
->booleanNode('verify_on_register')->isRequired()->end() |
|
101
|
|
|
->booleanNode('deny_unverified_login')->isRequired()->end() |
|
102
|
|
|
->end() |
|
103
|
|
|
->end() |
|
104
|
|
|
->arrayNode('change_email_address') |
|
105
|
|
|
->addDefaultsIfNotSet() |
|
106
|
|
|
->children() |
|
107
|
|
|
->scalarNode('default_verify_path')->isRequired()->end() |
|
108
|
|
|
->end() |
|
109
|
|
|
->end() |
|
110
|
|
|
->arrayNode('password_reset') |
|
111
|
|
|
->addDefaultsIfNotSet() |
|
112
|
|
|
->children() |
|
113
|
|
|
->scalarNode('default_reset_path')->isRequired()->end() |
|
114
|
|
|
->integerNode('repeat_ttl_seconds')->defaultValue(8600)->end() |
|
115
|
|
|
->integerNode('request_timeout_seconds')->defaultValue(3600)->end() |
|
116
|
|
|
->end() |
|
117
|
|
|
->end() |
|
118
|
|
|
->arrayNode('emails') |
|
119
|
|
|
->addDefaultsIfNotSet() |
|
120
|
|
|
->children() |
|
121
|
|
|
->booleanNode('user_welcome')->defaultValue(true)->end() |
|
122
|
|
|
->booleanNode('user_enabled')->defaultValue(true)->end() |
|
123
|
|
|
->booleanNode('user_username_changed')->defaultValue(true)->end() |
|
124
|
|
|
->booleanNode('user_password_changed')->defaultValue(true)->end() |
|
125
|
|
|
->end() |
|
126
|
|
|
->end() |
|
127
|
|
|
->end() |
|
128
|
|
|
->end() |
|
129
|
|
|
->end(); |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|