Settings: allow to retrieve stored value

This commit is contained in:
Thomas Gelf 2016-09-05 19:15:12 +00:00
parent 1144b5d55f
commit 0242d8d411
1 changed files with 13 additions and 6 deletions

View File

@ -16,7 +16,7 @@ class Settings
'config_format' => 'v2',
'override_services_varname' => '_override_servicevars',
'override_services_templatename' => 'host var overrides (Director)',
// 'disable_all_jobs' => null, // 'y'
'disable_all_jobs' => 'n', // 'y'
// 'experimental_features' => null, // 'allow'
// 'master_zone' => null,
);
@ -28,13 +28,20 @@ class Settings
}
public function get($key, $default = null)
{
if (null === ($value = $this->getStoredValue($key, $default))) {
return $this->getDefaultValue($key);
} else {
return $value;
}
}
public function getStoredValue($key, $default = null)
{
if (null === ($value = $this->getSetting($key))) {
if ($default === null) {
return $this->getDefaultValue($key);
} else {
return $default;
}
return $default;
} else {
return $value;
}
}