2019-02-03 16:22:04 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Factory;
|
|
|
|
|
|
|
|
use Friendica\Core\Config;
|
|
|
|
|
|
|
|
class ConfigFactory
|
|
|
|
{
|
2019-02-03 16:46:50 -05:00
|
|
|
/**
|
|
|
|
* @param Config\ConfigCacheLoader $loader The Config Cache loader (INI/config/.htconfig)
|
|
|
|
*
|
|
|
|
* @return Config\ConfigCache
|
|
|
|
*/
|
2019-02-03 16:22:04 -05:00
|
|
|
public static function createCache(Config\ConfigCacheLoader $loader)
|
|
|
|
{
|
|
|
|
$configCache = new Config\ConfigCache();
|
|
|
|
$loader->loadConfigFiles($configCache);
|
|
|
|
|
|
|
|
return $configCache;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $type The adapter type
|
|
|
|
* @param Config\IConfigCache $config The config cache of this adapter
|
2019-02-03 16:46:50 -05:00
|
|
|
*
|
2019-02-03 16:22:04 -05:00
|
|
|
* @return Config\IConfigAdapter
|
|
|
|
*/
|
|
|
|
public static function createConfig($type, $config)
|
|
|
|
{
|
|
|
|
if ($type == 'preload') {
|
|
|
|
return new Config\PreloadConfigAdapter($config);
|
|
|
|
} else {
|
|
|
|
return new Config\JITConfigAdapter($config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $type The adapter type
|
|
|
|
* @param Config\IPConfigCache $config The config cache of this adapter
|
2019-02-03 17:22:05 -05:00
|
|
|
* @param int $uid The UID of the current user
|
2019-02-03 16:46:50 -05:00
|
|
|
*
|
2019-02-03 16:22:04 -05:00
|
|
|
* @return Config\IPConfigAdapter
|
|
|
|
*/
|
2019-02-03 17:22:05 -05:00
|
|
|
public static function createPConfig($type, $config, $uid = null)
|
2019-02-03 16:22:04 -05:00
|
|
|
{
|
|
|
|
if ($type == 'preload') {
|
2019-02-03 17:22:05 -05:00
|
|
|
return new Config\PreloadPConfigAdapter($config, $uid);
|
2019-02-03 16:22:04 -05:00
|
|
|
} else {
|
|
|
|
return new Config\JITPConfigAdapter($config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|