2019-02-03 21:22:04 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Factory;
|
|
|
|
|
|
|
|
use Friendica\Core\Config;
|
2019-02-10 18:52:21 +00:00
|
|
|
use Friendica\Core\Config\Cache;
|
2019-07-12 21:01:01 +00:00
|
|
|
use Friendica\Model\Config\Config as ConfigModel;
|
2019-07-15 18:13:53 +00:00
|
|
|
use Friendica\Model\Config\PConfig as PConfigModel;
|
2019-07-20 23:22:10 +00:00
|
|
|
use Friendica\Util\ConfigFileLoader;
|
2019-02-03 21:22:04 +00:00
|
|
|
|
|
|
|
class ConfigFactory
|
|
|
|
{
|
2019-02-03 21:46:50 +00:00
|
|
|
/**
|
2019-03-24 11:54:26 +00:00
|
|
|
* @param ConfigFileLoader $loader The Config Cache loader (INI/config/.htconfig)
|
2019-02-03 21:46:50 +00:00
|
|
|
*
|
2020-01-19 21:23:44 +00:00
|
|
|
* @return Cache
|
2019-02-03 21:46:50 +00:00
|
|
|
*/
|
2019-07-20 23:22:10 +00:00
|
|
|
public function createCache(ConfigFileLoader $loader)
|
2019-02-03 21:22:04 +00:00
|
|
|
{
|
2020-01-19 21:23:44 +00:00
|
|
|
$configCache = new Cache();
|
2019-03-24 11:54:26 +00:00
|
|
|
$loader->setupCache($configCache);
|
2019-02-03 21:22:04 +00:00
|
|
|
|
|
|
|
return $configCache;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-01-19 21:23:44 +00:00
|
|
|
* @param Cache $configCache The config cache of this adapter
|
|
|
|
* @param ConfigModel $configModel The configuration model
|
2019-02-03 21:46:50 +00:00
|
|
|
*
|
2020-01-19 20:29:36 +00:00
|
|
|
* @return Config\IConfig
|
2019-02-03 21:22:04 +00:00
|
|
|
*/
|
2020-01-19 21:23:44 +00:00
|
|
|
public function createConfig(Cache $configCache, ConfigModel $configModel)
|
2019-02-03 21:22:04 +00:00
|
|
|
{
|
2019-02-10 18:52:21 +00:00
|
|
|
if ($configCache->get('system', 'config_adapter') === 'preload') {
|
2020-01-19 20:29:36 +00:00
|
|
|
$configuration = new Config\PreloadConfig($configCache, $configModel);
|
2019-02-03 21:22:04 +00:00
|
|
|
} else {
|
2020-01-19 20:29:36 +00:00
|
|
|
$configuration = new Config\JitConfig($configCache, $configModel);
|
2019-02-03 21:22:04 +00:00
|
|
|
}
|
2019-02-10 18:52:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
return $configuration;
|
2019-02-03 21:22:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-01-19 21:23:44 +00:00
|
|
|
* @param Cache $configCache The config cache
|
|
|
|
* @param \Friendica\Core\PConfig\Cache $pConfigCache The personal config cache
|
|
|
|
* @param PConfigModel $configModel The configuration model
|
2019-02-03 21:46:50 +00:00
|
|
|
*
|
2020-01-19 21:23:44 +00:00
|
|
|
* @return \Friendica\Core\PConfig\IPConfig
|
2019-02-03 21:22:04 +00:00
|
|
|
*/
|
2020-01-19 21:23:44 +00:00
|
|
|
public function createPConfig(Cache $configCache, \Friendica\Core\PConfig\Cache $pConfigCache, PConfigModel $configModel)
|
2019-02-03 21:22:04 +00:00
|
|
|
{
|
2019-02-10 18:52:21 +00:00
|
|
|
if ($configCache->get('system', 'config_adapter') === 'preload') {
|
2020-01-19 21:23:44 +00:00
|
|
|
$configuration = new \Friendica\Core\PConfig\PreloadPConfig($pConfigCache, $configModel);
|
2019-02-03 21:22:04 +00:00
|
|
|
} else {
|
2020-01-19 21:23:44 +00:00
|
|
|
$configuration = new \Friendica\Core\PConfig\JitPConfig($pConfigCache, $configModel);
|
2019-02-03 21:22:04 +00:00
|
|
|
}
|
2019-02-10 18:52:21 +00:00
|
|
|
|
|
|
|
return $configuration;
|
2019-02-03 21:22:04 +00:00
|
|
|
}
|
|
|
|
}
|