]> source.dussan.org Git - nextcloud-server.git/commitdiff
Deprecated \OCP\IAppConfig - add missing methods to IConfig
authorMorris Jobke <hey@morrisjobke.de>
Fri, 6 Feb 2015 09:02:21 +0000 (10:02 +0100)
committerMorris Jobke <hey@morrisjobke.de>
Tue, 17 Mar 2015 16:19:33 +0000 (17:19 +0100)
lib/private/allconfig.php
lib/private/legacy/appconfig.php
lib/public/iappconfig.php
lib/public/iconfig.php

index 8d4f13e5b9cf4b0853c0ec925c68b42769f0bf05..7057cc2f4243ee3ed5e1ee7cb1d16833c946255c 100644 (file)
@@ -8,6 +8,8 @@
  */
 
 namespace OC;
+
+use OCP\IAppConfig;
 use OCP\IDBConnection;
 use OCP\PreConditionNotMetException;
 
@@ -21,6 +23,9 @@ class AllConfig implements \OCP\IConfig {
        /** @var IDBConnection */
        private $connection;
 
+       /** @var IAppConfig */
+       private $appConfig;
+
        /**
         * 3 dimensional array with the following structure:
         * [ $userId =>
@@ -62,11 +67,17 @@ class AllConfig implements \OCP\IConfig {
         *
         * otherwise a SQLite database is created in the wrong directory
         * because the database connection was created with an uninitialized config
+        *
+        * The same applies for the app config, because it uses the database
+        * connection itself
         */
        private function fixDIInit() {
                if($this->connection === null) {
                        $this->connection = \OC::$server->getDatabaseConnection();
                }
+               if ($this->appConfig === null) {
+                       $this->appConfig = \OC::$server->getAppConfig();
+               }
        }
 
        /**
@@ -116,7 +127,10 @@ class AllConfig implements \OCP\IConfig {
         * @return string[] the keys stored for the app
         */
        public function getAppKeys($appName) {
-               return \OC::$server->getAppConfig()->getKeys($appName);
+               // TODO - FIXME
+               $this->fixDIInit();
+
+               return $this->appConfig->getKeys($appName);
        }
 
        /**
@@ -127,7 +141,24 @@ class AllConfig implements \OCP\IConfig {
         * @param string $value the value that should be stored
         */
        public function setAppValue($appName, $key, $value) {
-               \OC::$server->getAppConfig()->setValue($appName, $key, $value);
+               // TODO - FIXME
+               $this->fixDIInit();
+
+               $this->appConfig->setValue($appName, $key, $value);
+       }
+
+       /**
+        * Checks if a key is set in the apps config
+        *
+        * @param string $appName the appName tto look a key up
+        * @param string $key the key to look up
+        * @return bool
+        */
+       public function hasAppKey($appName, $key) {
+               // TODO - FIXME
+               $this->fixDIInit();
+
+               $this->appConfig->hasKey($appName, $key);
        }
 
        /**
@@ -139,7 +170,49 @@ class AllConfig implements \OCP\IConfig {
         * @return string the saved value
         */
        public function getAppValue($appName, $key, $default = '') {
-               return \OC::$server->getAppConfig()->getValue($appName, $key, $default);
+               // TODO - FIXME
+               $this->fixDIInit();
+
+               return $this->appConfig->getValue($appName, $key, $default);
+       }
+
+       /**
+        * Get all app values that are stored
+        *
+        * @param string $appName the appName
+        * @return array with key - value pair as they are saved previously
+        */
+       public function getAppValuesByApp($appName) {
+               // TODO - FIXME
+               $this->fixDIInit();
+
+               return $this->appConfig->getValues($appName, false);
+       }
+
+       /**
+        * Get all app values that use the same key
+        *
+        * @param string $key the appName
+        * @return array with key - value pair as they are saved previously with the
+        *                 app name as key
+        */
+       public function getAppValuesByKey($key) {
+               // TODO - FIXME
+               $this->fixDIInit();
+
+               return $this->appConfig->getValues(false, $key);
+       }
+
+       /**
+        * Get all apps that have at least one value saved
+        *
+        * @return array containing app names
+        */
+       public function getApps() {
+               // TODO - FIXME
+               $this->fixDIInit();
+
+               return $this->appConfig->getApps();
        }
 
        /**
@@ -149,7 +222,10 @@ class AllConfig implements \OCP\IConfig {
         * @param string $key the key of the value, under which it was saved
         */
        public function deleteAppValue($appName, $key) {
-               \OC::$server->getAppConfig()->deleteKey($appName, $key);
+               // TODO - FIXME
+               $this->fixDIInit();
+
+               $this->appConfig->deleteKey($appName, $key);
        }
 
        /**
@@ -158,7 +234,10 @@ class AllConfig implements \OCP\IConfig {
         * @param string $appName the appName the configs are stored under
         */
        public function deleteAppValues($appName) {
-               \OC::$server->getAppConfig()->deleteApp($appName);
+               // TODO - FIXME
+               $this->fixDIInit();
+
+               $this->appConfig->deleteApp($appName);
        }
 
 
index 68f63974e85d2c6fd0d458d34bc98b7a51136c69..9c87dce8c93916272e046e4afb0d4cc6b9dd9e8e 100644 (file)
@@ -25,7 +25,7 @@
  * This class provides an easy way for apps to store config values in the
  * database.
  *
- * @deprecated use \OC::$server->getAppConfig() to get an \OCP\IAppConfig instance
+ * @deprecated use \OC::$server->getConfig() to get an \OCP\IConfig instance
  */
 class OC_Appconfig {
        /**
index 3a976b4a26331976a1905404501cfb23112815be..27b9cb4248680a104abc59ca00c9f41ddcac4867 100644 (file)
@@ -10,6 +10,10 @@ namespace OCP;
 /**
  * This class provides an easy way for apps to store config values in the
  * database.
+ *
+ * @deprecated This interface will be dropped with ownCloud 10.1 which will be
+ *             released in the first quarter of 2017. Use the methods of
+ *             \OCP\IConfig instead
  */
 interface IAppConfig {
        /**
@@ -17,6 +21,7 @@ interface IAppConfig {
         * @param string $app
         * @param string $key
         * @return bool
+        * @deprecated use method hasAppKey of \OCP\IConfig
         */
        public function hasKey($app, $key);
 
@@ -59,6 +64,7 @@ interface IAppConfig {
         * @param string|false $key
         * @param string|false $app
         * @return array|false
+        * @deprecated use method getAppValuesByApp or getAppValuesByKey of \OCP\IConfig
         */
        public function getValues($app, $key);
 
@@ -77,6 +83,7 @@ interface IAppConfig {
        /**
         * Get all apps using the config
         * @return array an array of app ids
+        * @deprecated use method getApps of \OCP\IConfig
         *
         * This function returns a list of all apps that have at least one
         * entry in the appconfig table.
index 868a4133d2e39de76392c6732dca8c2341605c80..ec2b0b4cbb98cba7d5457d02b8cac1ead3bd863f 100644 (file)
@@ -84,6 +84,16 @@ interface IConfig {
         */
        public function setAppValue($appName, $key, $value);
 
+       /**
+        * Checks if a key is set in the apps config
+        *
+        * @param string $appName the appName tto look a key up
+        * @param string $key the key to look up
+        * @return bool
+        * @since 8.1.0
+        */
+       public function hasAppKey($appName, $key);
+
        /**
         * Looks up an app wide defined value
         *
@@ -94,6 +104,33 @@ interface IConfig {
         */
        public function getAppValue($appName, $key, $default = '');
 
+       /**
+        * Get all app values that are stored
+        *
+        * @param string $appName the appName
+        * @return array with key - value pair as they are saved previously
+        * @since 8.1.0
+        */
+       public function getAppValuesByApp($appName);
+
+       /**
+        * Get all app values that use the same key
+        *
+        * @param string $key the appName
+        * @return array with key - value pair as they are saved previously with the
+        *                   app name as key
+        * @since 8.1.0
+        */
+       public function getAppValuesByKey($key);
+
+       /**
+        * Get all apps that have at least one value saved
+        *
+        * @return array containing app names
+        * @since 8.1.0
+        */
+       public function getApps();
+
        /**
         * Delete an app wide defined value
         *