|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file defines the format of our configuration file |
|
4
|
|
|
* |
|
5
|
|
|
* @license https://github.com/allejo/bzion/blob/master/LICENSE.md GNU General Public License Version 3 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace BZIon\Config; |
|
9
|
|
|
|
|
10
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
11
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* BZIon's configuration |
|
15
|
|
|
*/ |
|
16
|
|
|
class Configuration implements ConfigurationInterface |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* Returns a configuration builder for bzion config files |
|
20
|
|
|
*/ |
|
21
|
|
|
public function getConfigTreeBuilder() |
|
22
|
|
|
{ |
|
23
|
|
|
$treeBuilder = new TreeBuilder(); |
|
24
|
|
|
$rootNode = $treeBuilder->root('bzion'); |
|
25
|
|
|
|
|
26
|
|
|
$rootNode |
|
27
|
|
|
->children() |
|
28
|
|
|
->arrayNode('mysql') |
|
29
|
|
|
->isRequired() |
|
30
|
|
|
->children() |
|
31
|
|
|
->scalarNode('host')->defaultValue('localhost')->isRequired()->attribute('asked', true)->end() |
|
32
|
|
|
->scalarNode('database')->defaultValue('bzion')->isRequired()->attribute('asked', true)->end() |
|
33
|
|
|
->scalarNode('username')->defaultValue('bzion_admin')->isRequired()->attribute('asked', true)->end() |
|
34
|
|
|
->scalarNode('password')->isRequired()->attribute('asked', true)->end() |
|
35
|
|
|
->end() |
|
36
|
|
|
->end() |
|
37
|
|
|
|
|
38
|
|
|
->arrayNode('site') |
|
39
|
|
|
->children() |
|
40
|
|
|
->scalarNode('name')->defaultValue('BZiON')->info('The name of the website')->attribute('asked', true)->end() |
|
41
|
|
|
->scalarNode('welcome')->defaultValue('Welcome to BZiON')->info('The main welcome message that appears on the landing page')->attribute('asked', true)->end() |
|
42
|
|
|
->scalarNode('slug')->defaultValue('A good clean League Management System ...sorta')->info('The secondary message that appears on the landing page')->attribute('asked', true)->end() |
|
43
|
|
|
->arrayNode('alert') |
|
44
|
|
|
->info('A site-wide alert that will be displayed') |
|
45
|
|
|
->addDefaultsIfNotSet() |
|
46
|
|
|
->canBeEnabled() |
|
47
|
|
|
->children() |
|
48
|
|
|
->booleanNode('collapsible')->defaultValue(false)->info('Whether or not the alert can be hidden per browser')->end() |
|
49
|
|
|
->scalarNode('header')->defaultValue('Alert Title')->info('The title of the alert')->end() |
|
50
|
|
|
->scalarNode('message')->defaultValue('Sample alert message with information')->info('The message of the alert')->end() |
|
51
|
|
|
->end() |
|
52
|
|
|
->end() |
|
53
|
|
|
->end() |
|
54
|
|
|
->end() |
|
55
|
|
|
|
|
56
|
|
|
->arrayNode('league') |
|
57
|
|
|
->isRequired() |
|
58
|
|
|
->children() |
|
59
|
|
|
->arrayNode('duration') |
|
60
|
|
|
->isRequired() |
|
61
|
|
|
->requiresAtLeastOneElement() |
|
62
|
|
|
->defaultValue(array( |
|
63
|
|
|
15 => '1/2', |
|
64
|
|
|
20 => '2/3', |
|
65
|
|
|
30 => '3/3' |
|
66
|
|
|
)) |
|
67
|
|
|
->useAttributeAsKey('minutes') |
|
68
|
|
|
->prototype('scalar')->end() |
|
69
|
|
|
->end() |
|
70
|
|
|
->end() |
|
71
|
|
|
->end() |
|
72
|
|
|
|
|
73
|
|
|
->arrayNode('email') |
|
74
|
|
|
->addDefaultsIfNotSet() |
|
75
|
|
|
->children() |
|
76
|
|
|
->scalarNode('from') |
|
77
|
|
|
->defaultNull() |
|
78
|
|
|
->attribute('asked', true) |
|
79
|
|
|
->info("The e-mail address that will be shown in the 'From:' field when sending messages. Leaving this to null will prevent any e-mails from being sent.") |
|
80
|
|
|
->example('[email protected]') |
|
81
|
|
|
->end() |
|
82
|
|
|
->end() |
|
83
|
|
|
->end() |
|
84
|
|
|
|
|
85
|
|
|
->arrayNode('api') |
|
86
|
|
|
->children() |
|
87
|
|
|
->arrayNode('allowed_ips') |
|
88
|
|
|
->prototype('scalar')->end() |
|
89
|
|
|
->defaultValue(array('127.0.0.1', '127.0.1.1')) |
|
90
|
|
|
->end() |
|
91
|
|
|
->end() |
|
92
|
|
|
->end() |
|
93
|
|
|
|
|
94
|
|
|
->arrayNode('logging') |
|
95
|
|
|
->children() |
|
96
|
|
|
->scalarNode('directory') |
|
97
|
|
|
->defaultValue('%bzion.root_dir%/app/logs') |
|
98
|
|
|
->info('The directory where BZiON log files will be stored') |
|
99
|
|
|
->end() |
|
100
|
|
|
->enumNode('level') |
|
101
|
|
|
->values(array( |
|
102
|
|
|
'debug', |
|
103
|
|
|
'info', |
|
104
|
|
|
'notice', |
|
105
|
|
|
'warning', |
|
106
|
|
|
'error', |
|
107
|
|
|
'critical', |
|
108
|
|
|
'alert', |
|
109
|
|
|
'emergency' |
|
110
|
|
|
)) |
|
111
|
|
|
->defaultValue('notice') |
|
112
|
|
|
->end() |
|
113
|
|
|
->end() |
|
114
|
|
|
->end() |
|
115
|
|
|
|
|
116
|
|
|
->arrayNode('features') |
|
117
|
|
|
->addDefaultsIfNotSet() |
|
118
|
|
|
->children() |
|
119
|
|
|
->arrayNode('websocket') |
|
120
|
|
|
->addDefaultsIfNotSet() |
|
121
|
|
|
->canBeEnabled() |
|
122
|
|
|
->info("Settings for the PHP web socket") |
|
123
|
|
|
->children() |
|
124
|
|
|
->integerNode('pull_port')->defaultValue(8591)->end() |
|
125
|
|
|
->integerNode('push_port')->defaultValue(8592)->end() |
|
126
|
|
|
->end() |
|
127
|
|
|
->end() |
|
128
|
|
|
->arrayNode('camo') |
|
129
|
|
|
->addDefaultsIfNotSet() |
|
130
|
|
|
->canBeEnabled() |
|
131
|
|
|
->info("Settings for the camo image proxy") |
|
132
|
|
|
->children() |
|
133
|
|
|
->scalarNode('base_url')->defaultNull()->end() |
|
134
|
|
|
->scalarNode('key')->defaultNull()->end() |
|
135
|
|
|
->arrayNode('whitelisted_domains') |
|
136
|
|
|
->prototype('scalar') |
|
137
|
|
|
->end() |
|
138
|
|
|
->end() |
|
139
|
|
|
->end() |
|
140
|
|
|
->end() |
|
141
|
|
|
->end() |
|
142
|
|
|
->end() |
|
143
|
|
|
|
|
144
|
|
|
->arrayNode('testing') |
|
145
|
|
|
->canBeEnabled() |
|
146
|
|
|
->children() |
|
147
|
|
|
->scalarNode('host')->defaultValue('localhost')->isRequired()->attribute('manual', true)->end() |
|
148
|
|
|
->scalarNode('database')->defaultValue('bzion_test')->isRequired()->attribute('manual', true)->end() |
|
149
|
|
|
->scalarNode('username')->defaultValue('bzion_test_admin')->isRequired()->attribute('manual', true)->end() |
|
150
|
|
|
->scalarNode('password')->isRequired()->attribute('manual', true)->end() |
|
151
|
|
|
->end() |
|
152
|
|
|
->attribute('manual', true) |
|
153
|
|
|
->end() |
|
154
|
|
|
|
|
155
|
|
|
->arrayNode('miscellaneous') |
|
156
|
|
|
->isRequired() |
|
157
|
|
|
->children() |
|
158
|
|
|
->scalarNode('list_server') |
|
159
|
|
|
->defaultValue('https://my.bzflag.org/db/?action=LIST&version=BZFS0221') |
|
160
|
|
|
->info('Path to the BZFlag List Server') |
|
161
|
|
|
->isRequired() |
|
162
|
|
|
->end() |
|
163
|
|
|
->scalarNode('admin') |
|
164
|
|
|
->info('The username of the user who will become the administrator of the instance') |
|
165
|
|
|
->example('brad') |
|
166
|
|
|
->attribute('asked', true) |
|
167
|
|
|
->defaultNull() |
|
168
|
|
|
->end() |
|
169
|
|
|
->scalarNode('update_interval') |
|
170
|
|
|
->defaultValue('5 minutes') |
|
171
|
|
|
->info('BZFlag server polling interval') |
|
172
|
|
|
->isRequired() |
|
173
|
|
|
->end() |
|
174
|
|
|
->enumNode('development') |
|
175
|
|
|
->values(array(false, true, 'force')) |
|
176
|
|
|
->defaultFalse() |
|
177
|
|
|
->attribute('asked', true) |
|
178
|
|
|
->info('Whether to enable some functions which make debugging easier') |
|
179
|
|
|
->attribute( |
|
180
|
|
|
'warning', |
|
181
|
|
|
'Setting this to anything other than false WILL introduce significant security risks and should NOT be done in a production environment' |
|
182
|
|
|
) |
|
183
|
|
|
->end() |
|
184
|
|
|
->scalarNode('maintenance') |
|
185
|
|
|
->defaultFalse() |
|
186
|
|
|
->info('Whether the website is in maintenance mode (you can set this to a markdown string to display it in the maintenance page)') |
|
187
|
|
|
->end() |
|
188
|
|
|
->end() |
|
189
|
|
|
->end() |
|
190
|
|
|
->end(); |
|
191
|
|
|
|
|
192
|
|
|
return $treeBuilder; |
|
193
|
|
|
} |
|
194
|
|
|
} |
|
195
|
|
|
|