]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Config/PreloadConfigAdapter.php
Merge pull request #6598 from annando/worker-index
[friendica.git] / src / Core / Config / PreloadConfigAdapter.php
index 4461105e149c1ec572173484106671c36bfe77fd..d5fbd982bf56e6f912fa5568c3168087819fdf61 100644 (file)
@@ -19,17 +19,20 @@ class PreloadConfigAdapter implements IConfigAdapter
        /**
         * @var IConfigCache The config cache of this driver
         */
-       private $config;
+       private $configCache;
 
        /**
-        * @param IConfigCache $config The config cache of this driver
+        * @param IConfigCache $configCache The config cache of this driver
         */
-       public function __construct($config)
+       public function __construct(IConfigCache $configCache)
        {
-               $this->config = $config;
+               $this->configCache = $configCache;
                $this->load();
        }
 
+       /**
+        * {@inheritdoc}
+        */
        public function load($family = 'config')
        {
                if ($this->config_loaded) {
@@ -38,27 +41,33 @@ class PreloadConfigAdapter implements IConfigAdapter
 
                $configs = DBA::select('config', ['cat', 'v', 'k']);
                while ($config = DBA::fetch($configs)) {
-                       $this->config->set($config['cat'], $config['k'], $config['v']);
+                       $this->configCache->set($config['cat'], $config['k'], $config['v']);
                }
                DBA::close($configs);
 
                $this->config_loaded = true;
        }
 
+       /**
+        * {@inheritdoc}
+        */
        public function get($cat, $k, $default_value = null, $refresh = false)
        {
                if ($refresh) {
                        $config = DBA::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]);
                        if (DBA::isResult($config)) {
-                               $this->config->set($cat, $k, $config['v']);
+                               $this->configCache->set($cat, $k, $config['v']);
                        }
                }
 
-               $return = $this->config->get($cat, $k, $default_value);
+               $return = $this->configCache->get($cat, $k, $default_value);
 
                return $return;
        }
 
+       /**
+        * {@inheritdoc}
+        */
        public function set($cat, $k, $value)
        {
                // We store our setting values as strings.
@@ -66,11 +75,11 @@ class PreloadConfigAdapter implements IConfigAdapter
                // The exception are array values.
                $compare_value = !is_array($value) ? (string)$value : $value;
 
-               if ($this->config->get($cat, $k) === $compare_value) {
+               if ($this->configCache->get($cat, $k) === $compare_value) {
                        return true;
                }
 
-               $this->config->set($cat, $k, $value);
+               $this->configCache->set($cat, $k, $value);
 
                // manage array value
                $dbvalue = is_array($value) ? serialize($value) : $value;
@@ -83,9 +92,12 @@ class PreloadConfigAdapter implements IConfigAdapter
                return true;
        }
 
+       /**
+        * {@inheritdoc}
+        */
        public function delete($cat, $k)
        {
-               $this->config->delete($cat, $k);
+               $this->configCache->delete($cat, $k);
 
                $result = DBA::delete('config', ['cat' => $cat, 'k' => $k]);