summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-12-18 14:54:38 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-12-18 14:54:38 +0100
commita743047e8228fb4973d99e0101dec5e6c39f81b9 (patch)
tree29b3856717f150181f867f530a61c6007388b49c /lib/private
parent50e877330700117ace281236ce7ecc1ae0f9521b (diff)
parent6fb60815c581c333106e0fa4845eb25ad6a5223b (diff)
downloadnextcloud-server-a743047e8228fb4973d99e0101dec5e6c39f81b9.tar.gz
nextcloud-server-a743047e8228fb4973d99e0101dec5e6c39f81b9.zip
Merge pull request #21283 from owncloud/cleanup_config
Cleanup OC_Config mess
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/app.php8
-rw-r--r--lib/private/helper.php2
-rw-r--r--lib/private/legacy/config.php94
-rw-r--r--lib/private/server.php7
-rw-r--r--lib/private/systemconfig.php17
-rw-r--r--lib/private/user.php4
-rw-r--r--lib/private/util.php12
7 files changed, 29 insertions, 115 deletions
diff --git a/lib/private/app.php b/lib/private/app.php
index e8cc9219224..ff711e82424 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -96,7 +96,7 @@ class OC_App {
* if $types is set, only apps of those types will be loaded
*/
public static function loadApps($types = null) {
- if (OC_Config::getValue('maintenance', false)) {
+ if (\OC::$server->getSystemConfig()->getValue('maintenance', false)) {
return false;
}
// Load the enabled apps here
@@ -239,7 +239,7 @@ class OC_App {
* @return string[]
*/
public static function getEnabledApps($forceRefresh = false, $all = false) {
- if (!OC_Config::getValue('installed', false)) {
+ if (!\OC::$server->getSystemConfig()->getValue('installed', false)) {
return array();
}
// in incognito mode or when logged out, $user will be false,
@@ -374,7 +374,7 @@ class OC_App {
$settings = array();
// by default, settings only contain the help menu
if (OC_Util::getEditionString() === '' &&
- OC_Config::getValue('knowledgebaseenabled', true) == true
+ \OC::$server->getSystemConfig()->getValue('knowledgebaseenabled', true) == true
) {
$settings = array(
array(
@@ -455,7 +455,7 @@ class OC_App {
* @return string|false
*/
public static function getInstallPath() {
- if (OC_Config::getValue('appstoreenabled', true) == false) {
+ if (\OC::$server->getSystemConfig()->getValue('appstoreenabled', true) == false) {
return false;
}
diff --git a/lib/private/helper.php b/lib/private/helper.php
index b4a5d8cddf5..b8f9f6ec138 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -657,7 +657,7 @@ class OC_Helper {
*/
public static function getStorageInfo($path, $rootInfo = null) {
// return storage info without adding mount points
- $includeExtStorage = \OC_Config::getValue('quota_include_external_storage', false);
+ $includeExtStorage = \OC::$server->getSystemConfig()->getValue('quota_include_external_storage', false);
if (!$rootInfo) {
$rootInfo = \OC\Files\Filesystem::getFileInfo($path, false);
diff --git a/lib/private/legacy/config.php b/lib/private/legacy/config.php
deleted file mode 100644
index 1835d4a4b1c..00000000000
--- a/lib/private/legacy/config.php
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php
-/**
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Joas Schilling <nickvergessen@owncloud.com>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
- * @author Lukas Reschke <lukas@owncloud.com>
- * @author Michael Gapczynski <GapczynskiM@gmail.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-/**
- * This class is responsible for reading and writing config.php, the very basic
- * configuration file of ownCloud.
- *
- * @deprecated use \OC::$server->getConfig() to get an \OCP\Config instance
- */
-class OC_Config {
-
- /** @var \OC\Config */
- public static $object;
-
- /**
- * Lists all available config keys
- * @return array an array of key names
- *
- * This function returns all keys saved in config.php. Please note that it
- * does not return the values.
- */
- public static function getKeys() {
- return self::$object->getKeys();
- }
-
- /**
- * Gets a value from config.php
- * @param string $key key
- * @param mixed $default = null default value
- * @return mixed the value or $default
- *
- * This function gets the value from config.php. If it does not exist,
- * $default will be returned.
- */
- public static function getValue($key, $default = null) {
- return self::$object->getValue($key, $default);
- }
-
- /**
- * Sets a value
- * @param string $key key
- * @param mixed $value value
- *
- * This function sets the value and writes the config.php.
- *
- */
- public static function setValue($key, $value) {
- self::$object->setValue($key, $value);
- }
-
- /**
- * Sets and deletes values and writes the config.php
- *
- * @param array $configs Associative array with `key => value` pairs
- * If value is null, the config key will be deleted
- */
- public static function setValues(array $configs) {
- self::$object->setValues($configs);
- }
-
- /**
- * Removes a key from the config
- * @param string $key key
- *
- * This function removes a key from the config.php.
- */
- public static function deleteKey($key) {
- self::$object->deleteKey($key);
- }
-}
diff --git a/lib/private/server.php b/lib/private/server.php
index 8439500706d..3e1af0310d1 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -84,8 +84,9 @@ class Server extends SimpleContainer implements IServerContainer {
/**
* @param string $webRoot
+ * @param \OC\Config $config
*/
- public function __construct($webRoot) {
+ public function __construct($webRoot, \OC\Config $config) {
parent::__construct();
$this->webRoot = $webRoot;
@@ -238,8 +239,8 @@ class Server extends SimpleContainer implements IServerContainer {
$c->getSystemConfig()
);
});
- $this->registerService('SystemConfig', function ($c) {
- return new \OC\SystemConfig();
+ $this->registerService('SystemConfig', function ($c) use ($config) {
+ return new \OC\SystemConfig($config);
});
$this->registerService('AppConfig', function ($c) {
return new \OC\AppConfig(\OC_DB::getConnection());
diff --git a/lib/private/systemconfig.php b/lib/private/systemconfig.php
index 94b815aebd7..fb8c18123d7 100644
--- a/lib/private/systemconfig.php
+++ b/lib/private/systemconfig.php
@@ -44,12 +44,19 @@ class SystemConfig {
'objectstore' => ['arguments' => ['password' => true]],
];
+ /** @var Config */
+ private $config;
+
+ public function __construct(Config $config) {
+ $this->config = $config;
+ }
+
/**
* Lists all available config keys
* @return array an array of key names
*/
public function getKeys() {
- return \OC_Config::getKeys();
+ return $this->config->getKeys();
}
/**
@@ -59,7 +66,7 @@ class SystemConfig {
* @param mixed $value the value that should be stored
*/
public function setValue($key, $value) {
- \OC_Config::setValue($key, $value);
+ $this->config->setValue($key, $value);
}
/**
@@ -69,7 +76,7 @@ class SystemConfig {
* If value is null, the config key will be deleted
*/
public function setValues(array $configs) {
- \OC_Config::setValues($configs);
+ $this->config->setValues($configs);
}
/**
@@ -80,7 +87,7 @@ class SystemConfig {
* @return mixed the value or $default
*/
public function getValue($key, $default = '') {
- return \OC_Config::getValue($key, $default);
+ return $this->config->getValue($key, $default);
}
/**
@@ -106,7 +113,7 @@ class SystemConfig {
* @param string $key the key of the value, under which it was saved
*/
public function deleteValue($key) {
- \OC_Config::deleteKey($key);
+ $this->config->deleteKey($key);
}
/**
diff --git a/lib/private/user.php b/lib/private/user.php
index f806aa07251..cfa60d675fe 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -130,7 +130,7 @@ class OC_User {
*/
public static function setupBackends() {
OC_App::loadApps(array('prelogin'));
- $backends = OC_Config::getValue('user_backends', array());
+ $backends = \OC::$server->getSystemConfig()->getValue('user_backends', array());
foreach ($backends as $i => $config) {
$class = $config['class'];
$arguments = $config['arguments'];
@@ -498,7 +498,7 @@ class OC_User {
if ($user) {
return $user->getHome();
} else {
- return OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid;
+ return \OC::$server->getSystemConfig()->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid;
}
}
diff --git a/lib/private/util.php b/lib/private/util.php
index 2ecacc53bd4..0e029d74b7d 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -72,7 +72,7 @@ class OC_Util {
private static function initLocalStorageRootFS() {
// mount local file backend as root
- $configDataDirectory = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
+ $configDataDirectory = \OC::$server->getSystemConfig()->getValue("datadirectory", OC::$SERVERROOT . "/data");
//first set up the local "root" storage
\OC\Files\Filesystem::initMountManager();
if (!self::$rootMounted) {
@@ -184,7 +184,7 @@ class OC_Util {
OC_Hook::emit('OC_Filesystem', 'preSetup', array('user' => $user));
//check if we are using an object storage
- $objectStore = OC_Config::getValue('objectstore');
+ $objectStore = \OC::$server->getSystemConfig()->getValue('objectstore', null);
if (isset($objectStore)) {
self::initObjectStoreRootFS($objectStore);
} else {
@@ -848,7 +848,7 @@ class OC_Util {
public static function checkDatabaseVersion() {
$l = \OC::$server->getL10N('lib');
$errors = array();
- $dbType = \OC_Config::getValue('dbtype', 'sqlite');
+ $dbType = \OC::$server->getSystemConfig()->getValue('dbtype', 'sqlite');
if ($dbType === 'pgsql') {
// check PostgreSQL version
try {
@@ -1108,11 +1108,11 @@ class OC_Util {
* @return string
*/
public static function getInstanceId() {
- $id = OC_Config::getValue('instanceid', null);
+ $id = \OC::$server->getSystemConfig()->getValue('instanceid', null);
if (is_null($id)) {
// We need to guarantee at least one letter in instanceid so it can be used as the session_name
$id = 'oc' . \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(10, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS);
- OC_Config::$object->setValue('instanceid', $id);
+ \OC::$server->getSystemConfig()->setValue('instanceid', $id);
}
return $id;
}
@@ -1364,7 +1364,7 @@ class OC_Util {
* @return string the theme
*/
public static function getTheme() {
- $theme = OC_Config::getValue("theme", '');
+ $theme = \OC::$server->getSystemConfig()->getValue("theme", '');
if ($theme === '') {
if (is_dir(OC::$SERVERROOT . '/themes/default')) {