]> git.mxchange.org Git - friendica.git/blobdiff - src/Factory/ConfigFactory.php
Fix notices
[friendica.git] / src / Factory / ConfigFactory.php
index 1f9662bddbdf1f15095c9f7dcc86ac4fc8c816ec..9a20100b2fe6da880d4877171c88c1c18a25b38a 100644 (file)
@@ -1,68 +1,83 @@
 <?php
+/**
+ * @copyright Copyright (C) 2010-2021, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
 
 namespace Friendica\Factory;
 
-use Friendica\Core;
+use Exception;
 use Friendica\Core\Config;
-use Friendica\Core\Config\Adapter;
 use Friendica\Core\Config\Cache;
-use Friendica\Util\Config\ConfigFileLoader;
+use Friendica\Model\Config\Config as ConfigModel;
+use Friendica\Model\Config\PConfig as PConfigModel;
+use Friendica\Util\ConfigFileLoader;
 
 class ConfigFactory
 {
        /**
         * @param ConfigFileLoader $loader The Config Cache loader (INI/config/.htconfig)
         *
-        * @return Cache\ConfigCache
+        * @return Cache
+        *
+        * @throws Exception
         */
-       public static function createCache(ConfigFileLoader $loader)
+       public function createCache(ConfigFileLoader $loader, array $server = [])
        {
-               $configCache = new Cache\ConfigCache();
-               $loader->setupCache($configCache);
+               $configCache = new Cache();
+               $loader->setupCache($configCache, $server);
 
                return $configCache;
        }
 
        /**
-        * @param Cache\ConfigCache $configCache The config cache of this adapter
+        * @param Cache       $configCache The config cache of this adapter
+        * @param ConfigModel $configModel The configuration model
         *
-        * @return Config\Configuration
+        * @return Config\IConfig
         */
-       public static function createConfig(Cache\ConfigCache $configCache)
+       public function createConfig(Cache $configCache, ConfigModel $configModel)
        {
                if ($configCache->get('system', 'config_adapter') === 'preload') {
-                       $configAdapter = new Adapter\PreloadConfigAdapter();
+                       $configuration = new Config\PreloadConfig($configCache, $configModel);
                } else {
-                       $configAdapter = new Adapter\JITConfigAdapter();
+                       $configuration = new Config\JitConfig($configCache, $configModel);
                }
 
-               $configuration = new Config\Configuration($configCache, $configAdapter);
-
-               // Set the config in the static container for legacy usage
-               Core\Config::init($configuration);
 
                return $configuration;
        }
 
        /**
-        * @param Cache\ConfigCache  $configCache The config cache of this adapter
-        * @param int                $uid         The UID of the current user
+        * @param Cache                         $configCache  The config cache
+        * @param \Friendica\Core\PConfig\Cache $pConfigCache The personal config cache
+        * @param PConfigModel                  $configModel  The configuration model
         *
-        * @return Config\PConfiguration
+        * @return \Friendica\Core\PConfig\IPConfig
         */
-       public static function createPConfig(Cache\ConfigCache $configCache, $uid = null)
+       public function createPConfig(Cache $configCache, \Friendica\Core\PConfig\Cache $pConfigCache, PConfigModel $configModel)
        {
                if ($configCache->get('system', 'config_adapter') === 'preload') {
-                       $configAdapter = new Adapter\PreloadPConfigAdapter($uid);
+                       $configuration = new \Friendica\Core\PConfig\PreloadPConfig($pConfigCache, $configModel);
                } else {
-                       $configAdapter = new Adapter\JITPConfigAdapter();
+                       $configuration = new \Friendica\Core\PConfig\JitPConfig($pConfigCache, $configModel);
                }
 
-               $configuration = new Config\PConfiguration($configCache, $configAdapter);
-
-               // Set the config in the static container for legacy usage
-               Core\PConfig::init($configuration);
-
                return $configuration;
        }
 }