Completed
Push — master ( c7af1e...46d491 )
by Konstantinos
06:03 queued 02:12
created

Configuration   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 179
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 7
Bugs 0 Features 2
Metric Value
wmc 1
c 7
b 0
f 2
lcom 0
cbo 3
dl 0
loc 179
ccs 148
cts 148
cp 1
rs 10

1 Method

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