]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Config/ConfigCache.php
Merge pull request #6581 from nupplaphil/config_refact
[friendica.git] / src / Core / Config / ConfigCache.php
index b50ba3e00450eaf40bf8d177d1164960325ac8d3..e03d3525666464a849e5c09e53f4179b3abdfb05 100644 (file)
@@ -2,23 +2,23 @@
 
 namespace Friendica\Core\Config;
 
+/**
+ * The Friendica config cache for the application
+ * Initial, all *.config.php files are loaded into this cache with the
+ * ConfigCacheLoader ( @see ConfigCacheLoader )
+ *
+ * Is used for further caching operations too (depending on the ConfigAdapter )
+ */
 class ConfigCache implements IConfigCache, IPConfigCache
 {
+       private $config;
+
        /**
-        * NEVER, EVER use this public config array outside of the class
-        * It is only public due to backward compatibility to .htconfig.php
-        *
-        * @var array The cached config array
+        * @param array $config    A initial config array
         */
-       public $config;
-
-       public function __construct($config = [], $overwrite = false)
+       public function __construct(array $config = [])
        {
-               $this->config = [];
-
-               if (isset($config)) {
-                       $this->loadConfigArray($config, $overwrite);
-               }
+               $this->config = $config;
        }
 
        /**
@@ -33,9 +33,9 @@ class ConfigCache implements IConfigCache, IPConfigCache
                foreach ($config as $category => $values) {
                        foreach ($values as $key => $value) {
                                if ($overwrite) {
-                                       self::set($category, $key, $value);
+                                       $this->set($category, $key, $value);
                                } else {
-                                       self::setDefault($category, $key, $value);
+                                       $this->setDefault($category, $key, $value);
                                }
                        }
                }
@@ -73,7 +73,7 @@ class ConfigCache implements IConfigCache, IPConfigCache
        private function setDefault($cat, $k, $v)
        {
                if (!isset($this->config[$cat][$k])) {
-                       self::set($cat, $k, $v);
+                       $this->set($cat, $k, $v);
                }
        }