]> git.mxchange.org Git - friendica.git/commitdiff
Move PConfig to strategies
authorPhilipp <admin@philipp.info>
Sun, 23 Jul 2023 01:19:38 +0000 (03:19 +0200)
committerPhilipp <admin@philipp.info>
Wed, 26 Jul 2023 17:18:23 +0000 (19:18 +0200)
src/Core/PConfig/Factory/PConfig.php
static/strategies.config.php

index cde97759e9a9530bb6c194983d9a5f7a44fd9159..4195619bc244afb5a40f40c31965851b79f97a37 100644 (file)
 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);
        }
 }
index 35afe2e5128fafaa8241a8faf4f0805d7b43991c..339a59a878b5f9ff4ec265ddf09c6a15c0084975 100644 (file)
@@ -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', ''],
+       ],
 ];