]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/PConfig.php
BBCode - fixed syntax error
[friendica.git] / src / Core / PConfig.php
index 2b6618930097c1c2ddf6c149b2a8d9286372331d..584318adbc65a4c0efa1368940d1d1961f15e649 100644 (file)
@@ -11,8 +11,6 @@ namespace Friendica\Core;
 use Friendica\App;
 use Friendica\BaseObject;
 
-require_once 'include/dba.php';
-
 /**
  * @brief Management of user configuration storage
  * Note:
@@ -23,21 +21,23 @@ require_once 'include/dba.php';
 class PConfig extends BaseObject
 {
        /**
-        * @var Friendica\Core\Config\IPConfigAdapter
+        * @var \Friendica\Core\Config\IPConfigAdapter
         */
        private static $adapter = null;
 
        public static function init($uid)
        {
+               $a = self::getApp();
+
                // Database isn't ready or populated yet
-               if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
+               if (!$a->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
                        return;
                }
 
-               if (self::getApp()->getConfigValue('system', 'config_adapter') == 'preload') {
+               if ($a->getConfigValue('system', 'config_adapter') == 'preload') {
                        self::$adapter = new Config\PreloadPConfigAdapter($uid);
                } else {
-                       self::$adapter = new Config\JITPConfigAdapter($uid);
+                       self::$adapter = new Config\JITPConfigAdapter();
                }
        }
 
@@ -51,11 +51,12 @@ class PConfig extends BaseObject
         * @param string $family The category of the configuration value
         *
         * @return void
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function load($uid, $family)
        {
                // Database isn't ready or populated yet
-               if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
+               if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
                        return;
                }
 
@@ -80,11 +81,12 @@ class PConfig extends BaseObject
         * @param boolean $refresh       optional, If true the config is loaded from the db and not from the cache (default: false)
         *
         * @return mixed Stored value or null if it does not exist
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function get($uid, $family, $key, $default_value = null, $refresh = false)
        {
                // Database isn't ready or populated yet
-               if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
+               if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
                        return;
                }
 
@@ -101,19 +103,20 @@ class PConfig extends BaseObject
         * Stores a config value ($value) in the category ($family) under the key ($key)
         * for the user_id $uid.
         *
-        * @note Please do not store booleans - convert to 0/1 integer values!
+        * @note  Please do not store booleans - convert to 0/1 integer values!
         *
         * @param string $uid    The user_id
         * @param string $family The category of the configuration value
         * @param string $key    The configuration key to set
-        * @param string $value  The value to store
+        * @param mixed  $value  The value to store
         *
         * @return bool Operation success
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function set($uid, $family, $key, $value)
        {
                // Database isn't ready or populated yet
-               if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
+               if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
                        return false;
                }
 
@@ -135,11 +138,12 @@ class PConfig extends BaseObject
         * @param string $key    The configuration key to delete
         *
         * @return mixed
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function delete($uid, $family, $key)
        {
                // Database isn't ready or populated yet
-               if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
+               if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
                        return false;
                }