1 | <?php |
||
12 | class Configuration { |
||
13 | |||
14 | const KEYMARKER = '____'; |
||
15 | |||
16 | /** @var Setting[] metadata as array of Settings objects */ |
||
17 | protected $settings = array(); |
||
18 | /** @var array problematic keys */ |
||
19 | protected $errors; |
||
20 | /** @var Setting[] undefined settings */ |
||
21 | protected $undefined = array(); |
||
22 | |||
23 | /** @var array all metadata */ |
||
24 | protected $metadata; |
||
25 | /** @var array all default settings */ |
||
26 | protected $default; |
||
27 | /** @var array all local settings */ |
||
28 | protected $local; |
||
29 | /** @var array all protected settings */ |
||
30 | protected $protected; |
||
31 | |||
32 | /** @var bool have the settings been changed since loading from disk? */ |
||
33 | protected $changed = false; |
||
34 | |||
35 | /** @var Loader */ |
||
36 | protected $loader; |
||
37 | /** @var Writer */ |
||
38 | protected $writer; |
||
39 | |||
40 | /** |
||
41 | * ConfigSettings constructor. |
||
42 | */ |
||
43 | public function __construct() { |
||
54 | |||
55 | /** |
||
56 | * Get all settings |
||
57 | * |
||
58 | * @return Setting[] |
||
59 | */ |
||
60 | public function getSettings() { |
||
63 | |||
64 | /** |
||
65 | * Get all unknown settings |
||
66 | * |
||
67 | * @return Setting[] |
||
68 | */ |
||
69 | public function getUndefined() { |
||
72 | |||
73 | /** |
||
74 | * Get the settings that had some kind of setup problem |
||
75 | * |
||
76 | * @return array associative error, key is the setting, value the error |
||
77 | */ |
||
78 | public function getErrors() { |
||
81 | |||
82 | /** |
||
83 | * Have the settings been changed since loading from disk? |
||
84 | * |
||
85 | * @return bool |
||
86 | */ |
||
87 | public function hasChanged() { |
||
90 | |||
91 | /** |
||
92 | * Check if the config can be written |
||
93 | * |
||
94 | * @return bool |
||
95 | */ |
||
96 | public function isLocked() { |
||
99 | |||
100 | /** |
||
101 | * Update the settings using the data provided |
||
102 | * |
||
103 | * @param array $input as posted |
||
104 | * @return bool true if all updates went through, false on errors |
||
105 | */ |
||
106 | public function updateSettings($input) { |
||
119 | |||
120 | /** |
||
121 | * Save the settings |
||
122 | * |
||
123 | * @throws \Exception |
||
124 | */ |
||
125 | public function save() { |
||
128 | |||
129 | /** |
||
130 | * Touch the settings |
||
131 | * |
||
132 | * @throws \Exception |
||
133 | */ |
||
134 | public function touch() { |
||
137 | |||
138 | /** |
||
139 | * Load the extension language strings |
||
140 | * |
||
141 | * @return array |
||
142 | */ |
||
143 | public function getLangs() { |
||
146 | |||
147 | /** |
||
148 | * Initalizes the $settings and $undefined properties |
||
149 | */ |
||
150 | protected function initSettings() { |
||
173 | |||
174 | /** |
||
175 | * Instantiates the proper class for the given config key |
||
176 | * |
||
177 | * The class is added to the $settings or $undefined arrays and returned |
||
178 | * |
||
179 | * @param string $key |
||
180 | * @return Setting |
||
181 | */ |
||
182 | protected function instantiateClass($key) { |
||
194 | |||
195 | /** |
||
196 | * Return the class to load |
||
197 | * |
||
198 | * @param string $class the class name as given in the meta file |
||
199 | * @param string $key the settings key |
||
200 | * @return string |
||
201 | */ |
||
202 | protected function determineClassName($class, $key) { |
||
216 | |||
217 | } |
||
218 |