aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/config
diff options
context:
space:
mode:
Diffstat (limited to 'application/config')
-rw-r--r--application/config/ConfigIO.php1
-rw-r--r--application/config/ConfigJson.php5
-rw-r--r--application/config/ConfigManager.php16
-rw-r--r--application/config/ConfigPhp.php3
-rw-r--r--application/config/ConfigPlugin.php4
5 files changed, 15 insertions, 14 deletions
diff --git a/application/config/ConfigIO.php b/application/config/ConfigIO.php
index be78b1c7..3efe5b6f 100644
--- a/application/config/ConfigIO.php
+++ b/application/config/ConfigIO.php
@@ -1,4 +1,5 @@
1<?php 1<?php
2namespace Shaarli\Config;
2 3
3/** 4/**
4 * Interface ConfigIO 5 * Interface ConfigIO
diff --git a/application/config/ConfigJson.php b/application/config/ConfigJson.php
index 6b5d73f1..30908d90 100644
--- a/application/config/ConfigJson.php
+++ b/application/config/ConfigJson.php
@@ -1,4 +1,5 @@
1<?php 1<?php
2namespace Shaarli\Config;
2 3
3/** 4/**
4 * Class ConfigJson (ConfigIO implementation) 5 * Class ConfigJson (ConfigIO implementation)
@@ -21,7 +22,7 @@ class ConfigJson implements ConfigIO
21 $data = json_decode($data, true); 22 $data = json_decode($data, true);
22 if ($data === null) { 23 if ($data === null) {
23 $error = json_last_error(); 24 $error = json_last_error();
24 throw new Exception('An error occurred while parsing JSON file: error code #'. $error); 25 throw new \Exception('An error occurred while parsing JSON file: error code #'. $error);
25 } 26 }
26 return $data; 27 return $data;
27 } 28 }
@@ -35,7 +36,7 @@ class ConfigJson implements ConfigIO
35 $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; 36 $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0;
36 $data = self::getPhpHeaders() . json_encode($conf, $print) . self::getPhpSuffix(); 37 $data = self::getPhpHeaders() . json_encode($conf, $print) . self::getPhpSuffix();
37 if (!file_put_contents($filepath, $data)) { 38 if (!file_put_contents($filepath, $data)) {
38 throw new IOException( 39 throw new \IOException(
39 $filepath, 40 $filepath,
40 'Shaarli could not create the config file. 41 'Shaarli could not create the config file.
41 Please make sure Shaarli has the right to write in the folder is it installed in.' 42 Please make sure Shaarli has the right to write in the folder is it installed in.'
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 2namespace Shaarli\Config;
3// FIXME! Namespaces...
4require_once 'ConfigIO.php';
5require_once 'ConfigJson.php';
6require_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 */
369class MissingFieldConfigException extends Exception 365class 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 */
388class UnauthorizedConfigException extends Exception 384class UnauthorizedConfigException extends \Exception
389{ 385{
390 /** 386 /**
391 * Construct exception. 387 * Construct exception.
diff --git a/application/config/ConfigPhp.php b/application/config/ConfigPhp.php
index d7fd4baf..2633824d 100644
--- a/application/config/ConfigPhp.php
+++ b/application/config/ConfigPhp.php
@@ -1,4 +1,5 @@
1<?php 1<?php
2namespace Shaarli\Config;
2 3
3/** 4/**
4 * Class ConfigPhp (ConfigIO implementation) 5 * Class ConfigPhp (ConfigIO implementation)
@@ -115,7 +116,7 @@ class ConfigPhp implements ConfigIO
115 if (!file_put_contents($filepath, $configStr) 116 if (!file_put_contents($filepath, $configStr)
116 || strcmp(file_get_contents($filepath), $configStr) != 0 117 || strcmp(file_get_contents($filepath), $configStr) != 0
117 ) { 118 ) {
118 throw new IOException( 119 throw new \IOException(
119 $filepath, 120 $filepath,
120 'Shaarli could not create the config file. 121 'Shaarli could not create the config file.
121 Please make sure Shaarli has the right to write in the folder is it installed in.' 122 Please make sure Shaarli has the right to write in the folder is it installed in.'
diff --git a/application/config/ConfigPlugin.php b/application/config/ConfigPlugin.php
index cb0b6fce..61a594d3 100644
--- a/application/config/ConfigPlugin.php
+++ b/application/config/ConfigPlugin.php
@@ -1,4 +1,6 @@
1<?php 1<?php
2namespace Shaarli\Config;
3
2/** 4/**
3 * Plugin configuration helper functions. 5 * Plugin configuration helper functions.
4 * 6 *
@@ -112,7 +114,7 @@ function load_plugin_parameter_values($plugins, $conf)
112/** 114/**
113 * Exception used if an error occur while saving plugin configuration. 115 * Exception used if an error occur while saving plugin configuration.
114 */ 116 */
115class PluginConfigOrderException extends Exception 117class PluginConfigOrderException extends \Exception
116{ 118{
117 /** 119 /**
118 * Construct exception. 120 * Construct exception.