X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FConfig%2FModel%2FConfig.php;h=46d5643b344bc66e4538b693b17bc400bcba296f;hb=21f172c585aff8c606774a05fde1548ddff1667d;hp=593ab04070f032628f9041b8c545c9fba1aead0b;hpb=92301c6464854381099b507d6d6f0dba610c807f;p=friendica.git diff --git a/src/Core/Config/Model/Config.php b/src/Core/Config/Model/Config.php index 593ab04070..46d5643b34 100644 --- a/src/Core/Config/Model/Config.php +++ b/src/Core/Config/Model/Config.php @@ -39,19 +39,32 @@ class Config implements IManageConfigValues /** @var ConfigFileManager */ protected $configFileManager; - /** @var array */ - protected $server; - /** * @param ConfigFileManager $configFileManager The configuration file manager to save back configs * @param Cache $configCache The configuration cache (based on the config-files) - * @param array $server The $_SERVER variable */ - public function __construct(ConfigFileManager $configFileManager, Cache $configCache, array $server = []) + public function __construct(ConfigFileManager $configFileManager, Cache $configCache) { $this->configFileManager = $configFileManager; $this->configCache = $configCache; - $this->server = $server; + } + + /** + * 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(); } /** @@ -76,6 +89,8 @@ class Config implements IManageConfigValues { try { $this->configFileManager->saveData($this->configCache); + // reload after the save to possible reload default values of lower source-priorities again + $this->reload(); } catch (ConfigFileException $e) { throw new ConfigPersistenceException('Cannot save config', $e); } @@ -87,20 +102,13 @@ class Config implements IManageConfigValues $configCache = new Cache(); try { - $this->configFileManager->setupCache($configCache, $this->server); + $this->configFileManager->setupCache($configCache); } catch (ConfigFileException $e) { throw new ConfigPersistenceException('Cannot reload config', $e); } $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) {