friendica/src/Factory/ConfigFactory.php
Philipp Holzer 6c2cf494b5
Remove DependencyFactory
- Include all necessary classes in `dependencies.config.php`
- Add DI-reference to BaseObject (acts as a global registry)
- Refactor all static "init()" methods to use the global registry

- Refactor Logging for Worker-Logger a little bit
2019-07-27 23:54:12 +02:00

62 lines
1.7 KiB
PHP

<?php
namespace Friendica\Factory;
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);
}
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);
}
return $configuration;
}
}