]> git.mxchange.org Git - friendica.git/blobdiff - src/Factory/ConfigFactory.php
There are no dead nodes anymore
[friendica.git] / src / Factory / ConfigFactory.php
index 4ab20d1d565afcfbce1917cff9f136cd178a01be..1f9662bddbdf1f15095c9f7dcc86ac4fc8c816ec 100644 (file)
@@ -2,51 +2,67 @@
 
 namespace Friendica\Factory;
 
+use Friendica\Core;
 use Friendica\Core\Config;
+use Friendica\Core\Config\Adapter;
+use Friendica\Core\Config\Cache;
+use Friendica\Util\Config\ConfigFileLoader;
 
 class ConfigFactory
 {
        /**
-        * @param Config\ConfigCacheLoader $loader The Config Cache loader (INI/config/.htconfig)
+        * @param ConfigFileLoader $loader The Config Cache loader (INI/config/.htconfig)
         *
-        * @return Config\ConfigCache
+        * @return Cache\ConfigCache
         */
-       public static function createCache(Config\ConfigCacheLoader $loader)
+       public static function createCache(ConfigFileLoader $loader)
        {
-               $configCache = new Config\ConfigCache();
-               $loader->loadConfigFiles($configCache);
+               $configCache = new Cache\ConfigCache();
+               $loader->setupCache($configCache);
 
                return $configCache;
        }
 
        /**
-        * @param string              $type   The adapter type
-        * @param Config\IConfigCache $config The config cache of this adapter
+        * @param Cache\ConfigCache $configCache The config cache of this adapter
         *
-        * @return Config\IConfigAdapter
+        * @return Config\Configuration
         */
-       public static function createConfig($type, $config)
+       public static function createConfig(Cache\ConfigCache $configCache)
        {
-               if ($type == 'preload') {
-                       return new Config\PreloadConfigAdapter($config);
+               if ($configCache->get('system', 'config_adapter') === 'preload') {
+                       $configAdapter = new Adapter\PreloadConfigAdapter();
                } else {
-                       return new Config\JITConfigAdapter($config);
+                       $configAdapter = new Adapter\JITConfigAdapter();
                }
+
+               $configuration = new Config\Configuration($configCache, $configAdapter);
+
+               // Set the config in the static container for legacy usage
+               Core\Config::init($configuration);
+
+               return $configuration;
        }
 
        /**
-        * @param string               $type   The adapter type
-        * @param int                  $uid    The UID of the current user
-        * @param Config\IPConfigCache $config The config cache of this adapter
+        * @param Cache\ConfigCache  $configCache The config cache of this adapter
+        * @param int                $uid         The UID of the current user
         *
-        * @return Config\IPConfigAdapter
+        * @return Config\PConfiguration
         */
-       public static function createPConfig($type, $uid, $config)
+       public static function createPConfig(Cache\ConfigCache $configCache, $uid = null)
        {
-               if ($type == 'preload') {
-                       return new Config\PreloadPConfigAdapter($uid, $config);
+               if ($configCache->get('system', 'config_adapter') === 'preload') {
+                       $configAdapter = new Adapter\PreloadPConfigAdapter($uid);
                } else {
-                       return new Config\JITPConfigAdapter($config);
+                       $configAdapter = new Adapter\JITPConfigAdapter();
                }
+
+               $configuration = new Config\PConfiguration($configCache, $configAdapter);
+
+               // Set the config in the static container for legacy usage
+               Core\PConfig::init($configuration);
+
+               return $configuration;
        }
 }