1 | <?php |
||
14 | class Configuration { |
||
15 | |||
16 | const KEYMARKER = '____'; |
||
17 | |||
18 | /** @var Setting[] metadata as array of Settings objects */ |
||
19 | protected $settings = array(); |
||
20 | /** @var array problematic keys */ |
||
21 | protected $errors; |
||
22 | /** @var Setting[] undefined settings */ |
||
23 | protected $undefined = array(); |
||
24 | |||
25 | /** @var array all metadata */ |
||
26 | protected $metadata; |
||
27 | /** @var array all default settings */ |
||
28 | protected $default; |
||
29 | /** @var array all local settings */ |
||
30 | protected $local; |
||
31 | /** @var array all protected settings */ |
||
32 | protected $protected; |
||
33 | |||
34 | /** @var bool have the settings been changed since loading from disk? */ |
||
35 | protected $changed = false; |
||
36 | |||
37 | /** @var Loader */ |
||
38 | protected $loader; |
||
39 | /** @var Writer */ |
||
40 | protected $writer; |
||
41 | |||
42 | /** |
||
43 | * ConfigSettings constructor. |
||
44 | */ |
||
45 | public function __construct() { |
||
56 | |||
57 | /** |
||
58 | * Get all settings |
||
59 | * |
||
60 | * @return Setting[] |
||
61 | */ |
||
62 | public function getSettings() { |
||
65 | |||
66 | /** |
||
67 | * Get all unknown settings |
||
68 | * |
||
69 | * @return Setting[] |
||
70 | */ |
||
71 | public function getUndefined() { |
||
74 | |||
75 | /** |
||
76 | * Get the settings that had some kind of setup problem |
||
77 | * |
||
78 | * @return array associative error, key is the setting, value the error |
||
79 | */ |
||
80 | public function getErrors() { |
||
83 | |||
84 | /** |
||
85 | * Have the settings been changed since loading from disk? |
||
86 | * |
||
87 | * @return bool |
||
88 | */ |
||
89 | public function hasChanged() { |
||
92 | |||
93 | /** |
||
94 | * Check if the config can be written |
||
95 | * |
||
96 | * @return bool |
||
97 | */ |
||
98 | public function isLocked() { |
||
101 | |||
102 | /** |
||
103 | * Update the settings using the data provided |
||
104 | * |
||
105 | * @param array $input as posted |
||
106 | * @return bool true if all updates went through, false on errors |
||
107 | */ |
||
108 | public function updateSettings($input) { |
||
121 | |||
122 | /** |
||
123 | * Save the settings |
||
124 | * |
||
125 | * @throws \Exception |
||
126 | */ |
||
127 | public function save() { |
||
130 | |||
131 | /** |
||
132 | * Touch the settings |
||
133 | * |
||
134 | * @throws \Exception |
||
135 | */ |
||
136 | public function touch() { |
||
139 | |||
140 | /** |
||
141 | * Load the extension language strings |
||
142 | * |
||
143 | * @return array |
||
144 | */ |
||
145 | public function getLangs() { |
||
148 | |||
149 | /** |
||
150 | * Initalizes the $settings and $undefined properties |
||
151 | */ |
||
152 | protected function initSettings() { |
||
175 | |||
176 | /** |
||
177 | * Instantiates the proper class for the given config key |
||
178 | * |
||
179 | * The class is added to the $settings or $undefined arrays and returned |
||
180 | * |
||
181 | * @param string $key |
||
182 | * @return Setting |
||
183 | */ |
||
184 | protected function instantiateClass($key) { |
||
196 | |||
197 | /** |
||
198 | * Return the class to load |
||
199 | * |
||
200 | * @param string $class the class name as given in the meta file |
||
201 | * @param string $key the settings key |
||
202 | * @return string |
||
203 | */ |
||
204 | protected function determineClassName($class, $key) { |
||
220 | |||
221 | } |
||
222 |