diff options
author | VirtualTam <virtualtam@flibidi.net> | 2017-03-03 23:06:12 +0100 |
---|---|---|
committer | VirtualTam <virtualtam@flibidi.net> | 2017-03-04 17:07:52 +0100 |
commit | 3c66e56435359dc678048193e8ee239d06f79b64 (patch) | |
tree | 38a4be4a9d9babc193683feec412ac008ca9a169 /application/config/ConfigManager.php | |
parent | 74198dcdf65ee3dd83cbe5b6a8a85bc386a62063 (diff) | |
download | Shaarli-3c66e56435359dc678048193e8ee239d06f79b64.tar.gz Shaarli-3c66e56435359dc678048193e8ee239d06f79b64.tar.zst Shaarli-3c66e56435359dc678048193e8ee239d06f79b64.zip |
application: introduce the Shaarli\Config namespace
Namespaces have been introduced with the REST API, and should be generalized
to the whole codebase to manage object scope and benefit from autoloading.
See:
- https://secure.php.net/manual/en/language.namespaces.php
- http://www.php-fig.org/psr/psr-4/
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'application/config/ConfigManager.php')
-rw-r--r-- | application/config/ConfigManager.php | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php index a401887c..679a75b3 100644 --- a/application/config/ConfigManager.php +++ b/application/config/ConfigManager.php | |||
@@ -1,9 +1,5 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | namespace Shaarli\Config; | |
3 | // FIXME! Namespaces... | ||
4 | require_once 'ConfigIO.php'; | ||
5 | require_once 'ConfigJson.php'; | ||
6 | require_once 'ConfigPhp.php'; | ||
7 | 3 | ||
8 | /** | 4 | /** |
9 | * Class ConfigManager | 5 | * Class ConfigManager |
@@ -124,12 +120,12 @@ class ConfigManager | |||
124 | * @param bool $write Write the new setting in the config file, default false. | 120 | * @param bool $write Write the new setting in the config file, default false. |
125 | * @param bool $isLoggedIn User login state, default false. | 121 | * @param bool $isLoggedIn User login state, default false. |
126 | * | 122 | * |
127 | * @throws Exception Invalid | 123 | * @throws \Exception Invalid |
128 | */ | 124 | */ |
129 | public function set($setting, $value, $write = false, $isLoggedIn = false) | 125 | public function set($setting, $value, $write = false, $isLoggedIn = false) |
130 | { | 126 | { |
131 | if (empty($setting) || ! is_string($setting)) { | 127 | if (empty($setting) || ! is_string($setting)) { |
132 | throw new Exception('Invalid setting key parameter. String expected, got: '. gettype($setting)); | 128 | throw new \Exception('Invalid setting key parameter. String expected, got: '. gettype($setting)); |
133 | } | 129 | } |
134 | 130 | ||
135 | // During the ConfigIO transition, map legacy settings to the new ones. | 131 | // During the ConfigIO transition, map legacy settings to the new ones. |
@@ -177,7 +173,7 @@ class ConfigManager | |||
177 | * | 173 | * |
178 | * @throws MissingFieldConfigException: a mandatory field has not been provided in $conf. | 174 | * @throws MissingFieldConfigException: a mandatory field has not been provided in $conf. |
179 | * @throws UnauthorizedConfigException: user is not authorize to change configuration. | 175 | * @throws UnauthorizedConfigException: user is not authorize to change configuration. |
180 | * @throws IOException: an error occurred while writing the new config file. | 176 | * @throws \IOException: an error occurred while writing the new config file. |
181 | */ | 177 | */ |
182 | public function write($isLoggedIn) | 178 | public function write($isLoggedIn) |
183 | { | 179 | { |
@@ -366,7 +362,7 @@ class ConfigManager | |||
366 | /** | 362 | /** |
367 | * Exception used if a mandatory field is missing in given configuration. | 363 | * Exception used if a mandatory field is missing in given configuration. |
368 | */ | 364 | */ |
369 | class MissingFieldConfigException extends Exception | 365 | class MissingFieldConfigException extends \Exception |
370 | { | 366 | { |
371 | public $field; | 367 | public $field; |
372 | 368 | ||
@@ -385,7 +381,7 @@ class MissingFieldConfigException extends Exception | |||
385 | /** | 381 | /** |
386 | * Exception used if an unauthorized attempt to edit configuration has been made. | 382 | * Exception used if an unauthorized attempt to edit configuration has been made. |
387 | */ | 383 | */ |
388 | class UnauthorizedConfigException extends Exception | 384 | class UnauthorizedConfigException extends \Exception |
389 | { | 385 | { |
390 | /** | 386 | /** |
391 | * Construct exception. | 387 | * Construct exception. |