friendica-github/src/Factory/ConfigFactory.php

62 lines
1.7 KiB
PHP
Raw Normal View History

2019-02-03 21:22:04 +00:00
<?php
namespace Friendica\Factory;
use Friendica\Core\Config;
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;
use Friendica\Util\ConfigFileLoader;
2019-02-03 21:22:04 +00:00
class ConfigFactory
{
/**
2019-03-24 11:54:26 +00:00
* @param ConfigFileLoader $loader The Config Cache loader (INI/config/.htconfig)
*
* @return Cache\ConfigCache
*/
public function createCache(ConfigFileLoader $loader)
2019-02-03 21:22:04 +00:00
{
$configCache = new Cache\ConfigCache();
2019-03-24 11:54:26 +00:00
$loader->setupCache($configCache);
2019-02-03 21:22:04 +00:00
return $configCache;
}
/**
2019-07-12 21:01:01 +00:00
* @param Cache\ConfigCache $configCache The config cache of this adapter
* @param ConfigModel $configModel The configuration model
*
* @return Config\IConfig
2019-02-03 21:22:04 +00:00
*/
public function createConfig(Cache\ConfigCache $configCache, ConfigModel $configModel)
2019-02-03 21:22:04 +00:00
{
if ($configCache->get('system', 'config_adapter') === 'preload') {
$configuration = new Config\PreloadConfig($configCache, $configModel);
2019-02-03 21:22:04 +00:00
} else {
$configuration = new Config\JitConfig($configCache, $configModel);
2019-02-03 21:22:04 +00:00
}
return $configuration;
2019-02-03 21:22:04 +00:00
}
/**
* @param Cache\ConfigCache $configCache The config cache
* @param Cache\PConfigCache $pConfigCache The personal config cache
* @param PConfigModel $configModel The configuration model
*
* @return Config\IPConfiguration
2019-02-03 21:22:04 +00:00
*/
public function createPConfig(Cache\ConfigCache $configCache, Cache\PConfigCache $pConfigCache, PConfigModel $configModel)
2019-02-03 21:22:04 +00:00
{
if ($configCache->get('system', 'config_adapter') === 'preload') {
2019-07-15 18:13:53 +00:00
$configuration = new Config\PreloadPConfiguration($pConfigCache, $configModel);
2019-02-03 21:22:04 +00:00
} else {
2019-07-15 18:13:53 +00:00
$configuration = new Config\JitPConfiguration($pConfigCache, $configModel);
2019-02-03 21:22:04 +00:00
}
return $configuration;
2019-02-03 21:22:04 +00:00
}
}