aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/config/ConfigJson.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2017-03-03 23:06:12 +0100
committerVirtualTam <virtualtam@flibidi.net>2017-03-04 17:07:52 +0100
commit3c66e56435359dc678048193e8ee239d06f79b64 (patch)
tree38a4be4a9d9babc193683feec412ac008ca9a169 /application/config/ConfigJson.php
parent74198dcdf65ee3dd83cbe5b6a8a85bc386a62063 (diff)
downloadShaarli-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/ConfigJson.php')
-rw-r--r--application/config/ConfigJson.php5
1 files changed, 3 insertions, 2 deletions
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.'