From: Philipp Date: Sun, 23 Jul 2023 01:19:38 +0000 (+0200) Subject: Move PConfig to strategies X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8ed94037d5022d75a9104ceebf06409d6c51c505;p=friendica.git Move PConfig to strategies --- diff --git a/src/Core/PConfig/Factory/PConfig.php b/src/Core/PConfig/Factory/PConfig.php index cde97759e9..4195619bc2 100644 --- a/src/Core/PConfig/Factory/PConfig.php +++ b/src/Core/PConfig/Factory/PConfig.php @@ -22,28 +22,16 @@ namespace Friendica\Core\PConfig\Factory; use Friendica\Core\Config\Capability\IManageConfigValues; +use Friendica\Core\Hooks\Capabilities\ICanCreateInstances; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; -use Friendica\Core\PConfig\Repository; -use Friendica\Core\PConfig\Type; -use Friendica\Core\PConfig\ValueObject; class PConfig { - /** - * @param IManageConfigValues $config The config - * @param ValueObject\Cache $pConfigCache The personal config cache - * @param Repository\PConfig $configRepo The configuration model - * - * @return IManagePersonalConfigValues - */ - public function create(IManageConfigValues $config, ValueObject\Cache $pConfigCache, Repository\PConfig $configRepo): IManagePersonalConfigValues + public function create(ICanCreateInstances $instanceCreator, IManageConfigValues $config): IManagePersonalConfigValues { - if ($config->get('system', 'config_adapter') === 'preload') { - $configuration = new Type\PreloadPConfig($pConfigCache, $configRepo); - } else { - $configuration = new Type\JitPConfig($pConfigCache, $configRepo); - } + $strategy = $config->get('system', 'config_adapter'); - return $configuration; + /** @var IManagePersonalConfigValues */ + return $instanceCreator->create(IManagePersonalConfigValues::class, $strategy); } } diff --git a/static/strategies.config.php b/static/strategies.config.php index 35afe2e512..339a59a878 100644 --- a/static/strategies.config.php +++ b/static/strategies.config.php @@ -22,6 +22,7 @@ use Friendica\Core\Cache; use Friendica\Core\Logger\Type; use Friendica\Core\KeyValueStorage; +use Friendica\Core\PConfig; use Psr\Log; return [ @@ -40,4 +41,8 @@ return [ KeyValueStorage\Capabilities\IManageKeyValuePairs::class => [ KeyValueStorage\Type\DBKeyValueStorage::class => ['database', ''], ], + PConfig\Capability\IManagePersonalConfigValues::class => [ + PConfig\Type\JitPConfig::class => ['jit'], + PConfig\Type\PreloadPConfig::class => ['preload', ''], + ], ];