/** @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();
}
/**
{
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);
}
$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)
{