X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fconsolidation%2Fconfig%2Fsrc%2FUtil%2FConfigFallback.php;fp=vendor%2Fconsolidation%2Fconfig%2Fsrc%2FUtil%2FConfigFallback.php;h=9f9972f6064eec4d88ceb9e7839c9374529aaaec;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/consolidation/config/src/Util/ConfigFallback.php b/vendor/consolidation/config/src/Util/ConfigFallback.php new file mode 100644 index 000000000..9f9972f60 --- /dev/null +++ b/vendor/consolidation/config/src/Util/ConfigFallback.php @@ -0,0 +1,51 @@ +getWithFallback($key, $this->group, $this->prefix, $this->postfix); + } + + /** + * Fetch an option value from a given key, or, if that specific key does + * not contain a value, then consult various fallback options until a + * value is found. + * + */ + protected function getWithFallback($key, $group, $prefix = '', $postfix = '.') + { + $configKey = "{$prefix}{$group}${postfix}{$key}"; + if ($this->config->has($configKey)) { + return $this->config->get($configKey); + } + if ($this->config->hasDefault($configKey)) { + return $this->config->getDefault($configKey); + } + $moreGeneralGroupname = $this->moreGeneralGroupName($group); + if ($moreGeneralGroupname) { + return $this->getWithFallback($key, $moreGeneralGroupname, $prefix, $postfix); + } + return null; + } +}