summaryrefslogtreecommitdiffstats
path: root/lib/private/systemconfig.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-11-27 16:40:12 +0100
committerMorris Jobke <hey@morrisjobke.de>2014-12-08 22:29:42 +0100
commit50c2a819a0c5ae50571d36a3e2dec4e8267fd13b (patch)
treec6241e94b567618b9f6e7952f45a3aaa11250d49 /lib/private/systemconfig.php
parentf219f5a7a62fe88b364b9a5f50e9730eba1ee84c (diff)
downloadnextcloud-server-50c2a819a0c5ae50571d36a3e2dec4e8267fd13b.tar.gz
nextcloud-server-50c2a819a0c5ae50571d36a3e2dec4e8267fd13b.zip
Extract interaction with config.php into SystemConfig
* introduce SystemConfig to avoid DI circle (used by database connection which is itself needed by AllConfig that itself contains the methods to access the config.php which then would need the database connection - did you get it? ;)) * use DI container and use that method in legacy code paths (for easier refactoring later) * create and use getSystemConfig instead of query() in DI container
Diffstat (limited to 'lib/private/systemconfig.php')
-rw-r--r--lib/private/systemconfig.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/private/systemconfig.php b/lib/private/systemconfig.php
new file mode 100644
index 00000000000..ce6883e5ab3
--- /dev/null
+++ b/lib/private/systemconfig.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Copyright (c) 2014 Morris Jobke <hey@morrisjobke.de>
+ * 2013 Bart Visscher <bartv@thisnet.nl>
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OC;
+
+/**
+ * Class which provides access to the system config values stored in config.php
+ * Internal class for bootstrap only.
+ * fixes cyclic DI: AllConfig needs AppConfig needs Database needs AllConfig
+ */
+class SystemConfig {
+ /**
+ * Sets a new system wide value
+ *
+ * @param string $key the key of the value, under which will be saved
+ * @param mixed $value the value that should be stored
+ */
+ public function setValue($key, $value) {
+ \OC_Config::setValue($key, $value);
+ }
+
+ /**
+ * Looks up a system wide defined value
+ *
+ * @param string $key the key of the value, under which it was saved
+ * @param mixed $default the default value to be returned if the value isn't set
+ * @return mixed the value or $default
+ */
+ public function getValue($key, $default = '') {
+ return \OC_Config::getValue($key, $default);
+ }
+
+ /**
+ * Delete a system wide defined value
+ *
+ * @param string $key the key of the value, under which it was saved
+ */
+ public function deleteValue($key) {
+ \OC_Config::deleteKey($key);
+ }
+}