From: Philipp Date: Wed, 11 Jan 2023 21:00:29 +0000 (+0100) Subject: Improve encapsulation X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fef10e8a57984a90a164102583a42de351502df8;p=friendica.git Improve encapsulation --- diff --git a/src/Core/Config/Capability/IManageConfigValues.php b/src/Core/Config/Capability/IManageConfigValues.php index 09e2cd9144..2c3d6da3c8 100644 --- a/src/Core/Config/Capability/IManageConfigValues.php +++ b/src/Core/Config/Capability/IManageConfigValues.php @@ -58,20 +58,6 @@ interface IManageConfigValues */ public function get(string $cat, string $key = null, $default_value = null); - /** - * Load all configuration values from a given cache and saves it back in the configuration node store - * @see ConfigFileManager::CONFIG_DATA_FILE - * - * All configuration values of the system are stored in the cache. - * - * @param Cache $cache a new cache - * - * @return void - * - * @throws ConfigPersistenceException In case the persistence layer throws errors - */ - public function load(Cache $cache); - /** * Sets a configuration value for system config * diff --git a/src/Core/Config/Model/Config.php b/src/Core/Config/Model/Config.php index 5258033a75..46d5643b34 100644 --- a/src/Core/Config/Model/Config.php +++ b/src/Core/Config/Model/Config.php @@ -49,6 +49,24 @@ class Config implements IManageConfigValues $this->configCache = $configCache; } + /** + * Load all configuration values from a given cache and saves it back in the configuration node store + * @see ConfigFileManager::CONFIG_DATA_FILE + * + * All configuration values of the system are stored in the cache. + * + * @param Cache $cache a new cache + * + * @return void + * + * @throws ConfigPersistenceException In case the persistence layer throws errors + */ + public function setCacheAndSave(Cache $cache) + { + $this->configCache = $cache; + $this->save(); + } + /** * {@inheritDoc} */ @@ -91,13 +109,6 @@ class Config implements IManageConfigValues $this->configCache = $configCache; } - /** {@inheritDoc} */ - public function load(Cache $cache) - { - $this->configCache = $cache; - $this->save(); - } - /** {@inheritDoc} */ public function get(string $cat, string $key = null, $default_value = null) { diff --git a/src/Core/Config/Model/ConfigTransaction.php b/src/Core/Config/Model/ConfigTransaction.php index ec0a2b9c8b..b9310301f3 100644 --- a/src/Core/Config/Model/ConfigTransaction.php +++ b/src/Core/Config/Model/ConfigTransaction.php @@ -57,7 +57,7 @@ class ConfigTransaction implements ISetConfigValuesTransactionally /** {@inheritDoc} */ public function delete(string $cat, string $key): ISetConfigValuesTransactionally { - $this->cache->delete($cat, $key, Cache::SOURCE_DATA); + $this->cache->delete($cat, $key); $this->changedConfig = true; return $this; @@ -72,7 +72,7 @@ class ConfigTransaction implements ISetConfigValuesTransactionally } try { - $this->config->load($this->cache); + $this->config->setCacheAndSave($this->cache); $this->cache = clone $this->config->getCache(); } catch (\Exception $e) { throw new ConfigPersistenceException('Cannot save config', $e); diff --git a/src/Core/Config/ValueObject/Cache.php b/src/Core/Config/ValueObject/Cache.php index be42ae1181..acfac3ab9a 100644 --- a/src/Core/Config/ValueObject/Cache.php +++ b/src/Core/Config/ValueObject/Cache.php @@ -56,7 +56,7 @@ class Cache private $source = []; /** - * @var array + * @var bool[][] */ private $delConfig = [];