eafcf3592d
- New Configuration (Config is now only holding the instance) - New PConfiguration (PConfig is now only holding the instance) - Config & PConfig-Adapter don't need "ConfigCache" anymore - DB-Connection is now outside App->reload() for better dependency-chaining
67 lines
1.7 KiB
PHP
67 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Friendica\Factory;
|
|
|
|
use Friendica\Core;
|
|
use Friendica\Core\Config;
|
|
use Friendica\Core\Config\Adapter;
|
|
use Friendica\Core\Config\Cache;
|
|
|
|
class ConfigFactory
|
|
{
|
|
/**
|
|
* @param Cache\ConfigCacheLoader $loader The Config Cache loader (INI/config/.htconfig)
|
|
*
|
|
* @return Cache\ConfigCache
|
|
*/
|
|
public static function createCache(Cache\ConfigCacheLoader $loader)
|
|
{
|
|
$configCache = new Cache\ConfigCache();
|
|
$loader->loadConfigFiles($configCache);
|
|
|
|
return $configCache;
|
|
}
|
|
|
|
/**
|
|
* @param Cache\ConfigCache $configCache The config cache of this adapter
|
|
*
|
|
* @return Config\Configuration
|
|
*/
|
|
public static function createConfig(Cache\ConfigCache $configCache)
|
|
{
|
|
if ($configCache->get('system', 'config_adapter') === 'preload') {
|
|
$configAdapter = new Adapter\PreloadConfigAdapter();
|
|
} else {
|
|
$configAdapter = new Adapter\JITConfigAdapter();
|
|
}
|
|
|
|
$configuration = new Config\Configuration($configCache, $configAdapter);
|
|
|
|
// Set the config in the static container for legacy usage
|
|
Core\Config::init($configuration);
|
|
|
|
return $configuration;
|
|
}
|
|
|
|
/**
|
|
* @param Cache\ConfigCache $configCache The config cache of this adapter
|
|
* @param int $uid The UID of the current user
|
|
*
|
|
* @return Config\PConfiguration
|
|
*/
|
|
public static function createPConfig(Cache\ConfigCache $configCache, $uid = null)
|
|
{
|
|
if ($configCache->get('system', 'config_adapter') === 'preload') {
|
|
$configAdapter = new Adapter\PreloadPConfigAdapter($uid);
|
|
} else {
|
|
$configAdapter = new Adapter\JITPConfigAdapter();
|
|
}
|
|
|
|
$configuration = new Config\PConfiguration($configCache, $configAdapter);
|
|
|
|
// Set the config in the static container for legacy usage
|
|
Core\PConfig::init($configuration);
|
|
|
|
return $configuration;
|
|
}
|
|
}
|