From 0242d8d41126333a02f888de7a3a0af9552d0ad5 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 5 Sep 2016 19:15:12 +0000 Subject: [PATCH] Settings: allow to retrieve stored value --- library/Director/Settings.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/library/Director/Settings.php b/library/Director/Settings.php index 69fb7d8b..165416d2 100644 --- a/library/Director/Settings.php +++ b/library/Director/Settings.php @@ -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; } }