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->addSecurityNode($rootNode); |
36
|
1 |
|
$this->addEnabledComponentsNode($rootNode); |
37
|
1 |
|
$this->addUserNode($rootNode); |
38
|
|
|
|
39
|
1 |
|
return $treeBuilder; |
40
|
|
|
} |
41
|
|
|
|
42
|
1 |
|
private function addSecurityNode(ArrayNodeDefinition $rootNode): void |
43
|
|
|
{ |
44
|
|
|
$rootNode |
45
|
1 |
|
->children() |
46
|
1 |
|
->arrayNode('security') |
47
|
1 |
|
->addDefaultsIfNotSet() |
48
|
1 |
|
->children() |
49
|
1 |
|
->arrayNode('tokens') |
50
|
1 |
|
->prototype('scalar')->end() |
51
|
1 |
|
->end() |
|
|
|
|
52
|
1 |
|
->end() |
53
|
1 |
|
->end() |
54
|
1 |
|
->end(); |
55
|
1 |
|
} |
56
|
|
|
|
57
|
1 |
|
private function addEnabledComponentsNode(ArrayNodeDefinition $rootNode): void |
58
|
|
|
{ |
59
|
|
|
$rootNode |
60
|
1 |
|
->children() |
61
|
1 |
|
->arrayNode('enabled_components') |
62
|
1 |
|
->addDefaultsIfNotSet() |
63
|
1 |
|
->children() |
64
|
1 |
|
->booleanNode('form')->defaultValue(true)->end() |
65
|
1 |
|
->booleanNode('collection')->defaultValue(true)->end() |
|
|
|
|
66
|
1 |
|
->end() |
67
|
1 |
|
->end() |
68
|
1 |
|
->end(); |
69
|
1 |
|
} |
70
|
|
|
|
71
|
1 |
|
private function addUserNode(ArrayNodeDefinition $rootNode): void |
72
|
|
|
{ |
73
|
|
|
$rootNode |
74
|
1 |
|
->children() |
75
|
1 |
|
->arrayNode('user') |
76
|
1 |
|
->addDefaultsIfNotSet() |
77
|
1 |
|
->children() |
78
|
1 |
|
->scalarNode('class_name')->isRequired()->end() |
79
|
1 |
|
->arrayNode('email_verification') |
|
|
|
|
80
|
1 |
|
->addDefaultsIfNotSet() |
81
|
1 |
|
->children() |
82
|
1 |
|
->booleanNode('default')->isRequired()->end() |
83
|
1 |
|
->booleanNode('verify_on_register')->isRequired()->end() |
84
|
1 |
|
->booleanNode('deny_unverified_login')->isRequired()->end() |
85
|
1 |
|
->end() |
86
|
1 |
|
->end() |
87
|
1 |
|
->arrayNode('change_email_address') |
88
|
1 |
|
->addDefaultsIfNotSet() |
89
|
1 |
|
->children() |
90
|
1 |
|
->scalarNode('default_verify_path')->isRequired()->end() |
91
|
1 |
|
->end() |
92
|
1 |
|
->end() |
93
|
1 |
|
->arrayNode('password_reset') |
94
|
1 |
|
->addDefaultsIfNotSet() |
95
|
1 |
|
->children() |
96
|
1 |
|
->scalarNode('default_reset_path')->isRequired()->end() |
97
|
1 |
|
->integerNode('repeat_ttl_seconds')->defaultValue(8600)->end() |
98
|
1 |
|
->integerNode('request_timeout_seconds')->defaultValue(3600)->end() |
99
|
1 |
|
->end() |
100
|
1 |
|
->end() |
101
|
1 |
|
->arrayNode('emails') |
102
|
1 |
|
->addDefaultsIfNotSet() |
103
|
1 |
|
->children() |
104
|
1 |
|
->booleanNode('user_welcome')->defaultValue(true)->end() |
105
|
1 |
|
->booleanNode('user_enabled')->defaultValue(true)->end() |
106
|
1 |
|
->booleanNode('user_username_changed')->defaultValue(true)->end() |
107
|
1 |
|
->booleanNode('user_password_changed')->defaultValue(true)->end() |
108
|
1 |
|
->end() |
109
|
1 |
|
->end() |
110
|
1 |
|
->end() |
111
|
1 |
|
->end() |
112
|
1 |
|
->end(); |
113
|
1 |
|
} |
114
|
|
|
} |
115
|
|
|
|