mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-02-04 13:06:53 +00:00
Adapt GetEnvironmentalVariableOrConfig() to get() and set()
Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
parent
4b011369ae
commit
9be2c36a6b
1 changed files with 10 additions and 12 deletions
|
|
@ -654,23 +654,21 @@ class ConfigurationManager
|
|||
|
||||
private function GetEnvironmentalVariableOrConfig(string $envVariableName, string $configName, string $defaultValue) : string {
|
||||
$envVariableOutput = getenv($envVariableName);
|
||||
$configValue = $this->get($configName, '');
|
||||
if ($envVariableOutput === false) {
|
||||
$config = $this->GetConfig();
|
||||
if (!isset($config[$configName]) || $config[$configName] === '') {
|
||||
$config[$configName] = $defaultValue;
|
||||
if ($configValue === '') {
|
||||
$this->set($configName, $defaultValue);
|
||||
return $defaultValue;
|
||||
}
|
||||
return $config[$configName];
|
||||
return $configValue;
|
||||
}
|
||||
if(file_exists(DataConst::GetConfigFile())) {
|
||||
$config = $this->GetConfig();
|
||||
if (!isset($config[$configName])) {
|
||||
$config[$configName] = '';
|
||||
}
|
||||
if ($envVariableOutput !== $config[$configName]) {
|
||||
$config[$configName] = $envVariableOutput;
|
||||
$this->WriteConfig($config);
|
||||
|
||||
if (file_exists(DataConst::GetConfigFile())) {
|
||||
if ($envVariableOutput !== $configValue) {
|
||||
$this->set($configName, $envVariableOutput);
|
||||
}
|
||||
}
|
||||
|
||||
return $envVariableOutput;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue