mirror of
https://github.com/friendica/friendica
synced 2024-11-10 02:22:55 +00:00
Improve encapsulation
This commit is contained in:
parent
11a8bd17e3
commit
fef10e8a57
4 changed files with 21 additions and 24 deletions
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -56,7 +56,7 @@ class Cache
|
|||
private $source = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var bool[][]
|
||||
*/
|
||||
private $delConfig = [];
|
||||
|
||||
|
|
Loading…
Reference in a new issue