X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFactory%2FConfigFactory.php;h=9a20100b2fe6da880d4877171c88c1c18a25b38a;hb=5d61599964e74bb733816a5592eee2aed3bbba4e;hp=269daea8b8d5514d6a19497a912dc43d54c50506;hpb=75728430832633407c78a49d47481e97bbd9e00e;p=friendica.git diff --git a/src/Factory/ConfigFactory.php b/src/Factory/ConfigFactory.php index 269daea8b8..9a20100b2f 100644 --- a/src/Factory/ConfigFactory.php +++ b/src/Factory/ConfigFactory.php @@ -1,52 +1,83 @@ . + * + */ namespace Friendica\Factory; +use Exception; use Friendica\Core\Config; +use Friendica\Core\Config\Cache; +use Friendica\Model\Config\Config as ConfigModel; +use Friendica\Model\Config\PConfig as PConfigModel; +use Friendica\Util\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 + * + * @throws Exception */ - public static function createCache(Config\ConfigCacheLoader $loader) + public function createCache(ConfigFileLoader $loader, array $server = []) { - $configCache = new Config\ConfigCache(); - $loader->loadConfigFiles($configCache); + $configCache = new Cache(); + $loader->setupCache($configCache, $server); return $configCache; } /** - * @param string $type The adapter type - * @param Config\IConfigCache $config The config cache of this adapter + * @param Cache $configCache The config cache of this adapter + * @param ConfigModel $configModel The configuration model * - * @return Config\IConfigAdapter + * @return Config\IConfig */ - public static function createConfig($type, Config\IConfigCache $config) + public function createConfig(Cache $configCache, ConfigModel $configModel) { - if ($type == 'preload') { - return new Config\PreloadConfigAdapter($config); + if ($configCache->get('system', 'config_adapter') === 'preload') { + $configuration = new Config\PreloadConfig($configCache, $configModel); } else { - return new Config\JITConfigAdapter($config); + $configuration = new Config\JitConfig($configCache, $configModel); } + + + return $configuration; } /** - * @param string $type The adapter type - * @param Config\IPConfigCache $config 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\IPConfigAdapter + * @return \Friendica\Core\PConfig\IPConfig */ - public static function createPConfig($type, Config\IPConfigCache $config, $uid = null) + public function createPConfig(Cache $configCache, \Friendica\Core\PConfig\Cache $pConfigCache, PConfigModel $configModel) { - if ($type == 'preload') { - return new Config\PreloadPConfigAdapter($config, $uid); + if ($configCache->get('system', 'config_adapter') === 'preload') { + $configuration = new \Friendica\Core\PConfig\PreloadPConfig($pConfigCache, $configModel); } else { - return new Config\JITPConfigAdapter($config); + $configuration = new \Friendica\Core\PConfig\JitPConfig($pConfigCache, $configModel); } + + return $configuration; } }