mirror of
https://github.com/friendica/friendica
synced 2024-05-17 05:16:44 +02:00
55999730e0
- Adding dice library - Adding dependency config - Removing Factories - Refactoring App\Mode constructor - Refactoring App\Router constructor - Refactoring BasePath for DI usage - Refactoring ConfigFileLoader constructor - Refactoring Profiler constructor - Adjust entrypoints (index, console, worker, ..) - Adding functional test for DI - Fix tests because of refactorings
69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Friendica\Factory;
|
|
|
|
use Friendica\Core;
|
|
use Friendica\Core\Config;
|
|
use Friendica\Core\Config\Cache;
|
|
use Friendica\Model\Config\Config as ConfigModel;
|
|
use Friendica\Model\Config\PConfig as PConfigModel;
|
|
use Friendica\Util\ConfigFileLoader;
|
|
|
|
class ConfigFactory
|
|
{
|
|
/**
|
|
* @param ConfigFileLoader $loader The Config Cache loader (INI/config/.htconfig)
|
|
*
|
|
* @return Cache\ConfigCache
|
|
*/
|
|
public function createCache(ConfigFileLoader $loader)
|
|
{
|
|
$configCache = new Cache\ConfigCache();
|
|
$loader->setupCache($configCache);
|
|
|
|
return $configCache;
|
|
}
|
|
|
|
/**
|
|
* @param Cache\ConfigCache $configCache The config cache of this adapter
|
|
* @param ConfigModel $configModel The configuration model
|
|
*
|
|
* @return Config\Configuration
|
|
*/
|
|
public function createConfig(Cache\ConfigCache $configCache, ConfigModel $configModel)
|
|
{
|
|
if ($configCache->get('system', 'config_adapter') === 'preload') {
|
|
$configuration = new Config\PreloadConfiguration($configCache, $configModel);
|
|
} else {
|
|
$configuration = new Config\JitConfiguration($configCache, $configModel);
|
|
}
|
|
|
|
|
|
// Set the config in the static container for legacy usage
|
|
Core\Config::init($configuration);
|
|
|
|
return $configuration;
|
|
}
|
|
|
|
/**
|
|
* @param Cache\ConfigCache $configCache The config cache
|
|
* @param Cache\PConfigCache $pConfigCache The personal config cache
|
|
* @param PConfigModel $configModel The configuration model
|
|
*
|
|
* @return Config\PConfiguration
|
|
*/
|
|
public function createPConfig(Cache\ConfigCache $configCache, Cache\PConfigCache $pConfigCache, PConfigModel $configModel)
|
|
{
|
|
if ($configCache->get('system', 'config_adapter') === 'preload') {
|
|
$configuration = new Config\PreloadPConfiguration($pConfigCache, $configModel);
|
|
} else {
|
|
$configuration = new Config\JitPConfiguration($pConfigCache, $configModel);
|
|
}
|
|
|
|
// Set the config in the static container for legacy usage
|
|
Core\PConfig::init($configuration);
|
|
|
|
return $configuration;
|
|
}
|
|
}
|