Improve encapsulation

This commit is contained in:
Philipp Holzer 2023-01-11 22:00:29 +01:00
parent 11a8bd17e3
commit fef10e8a57
Signed by: nupplaPhil
GPG Key ID: 24A7501396EB5432
4 changed files with 21 additions and 24 deletions

View File

@ -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
*

View File

@ -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)
{

View File

@ -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);

View File

@ -56,7 +56,7 @@ class Cache
private $source = [];
/**
* @var array
* @var bool[][]
*/
private $delConfig = [];