friendica/src/Factory/ConfigFactory.php
2019-02-04 09:30:48 +01:00

52 lines
1.3 KiB
PHP

<?php
namespace Friendica\Factory;
use Friendica\Core\Config;
class ConfigFactory
{
/**
* @param Config\ConfigCacheLoader $loader The Config Cache loader (INI/config/.htconfig)
*
* @return Config\ConfigCache
*/
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
*
* @return Config\IConfigAdapter
*/
public static function createConfig($type, Config\IConfigCache $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
* @param int $uid The UID of the current user
*
* @return Config\IPConfigAdapter
*/
public static function createPConfig($type, Config\IPConfigCache $config, $uid = null)
{
if ($type == 'preload') {
return new Config\PreloadPConfigAdapter($config, $uid);
} else {
return new Config\JITPConfigAdapter($config);
}
}
}