2 namespace Consolidation\Config\Util;
5 * Works like 'getWithFallback', but merges results from all applicable
6 * groups. Settings from most specific group take precedence.
8 class ConfigMerge extends ConfigGroup
13 public function get($key)
15 return $this->getWithMerge($key, $this->group, $this->prefix, $this->postfix);
19 * Merge available configuration from each configuration group.
21 public function getWithMerge($key, $group, $prefix = '', $postfix = '.')
23 $configKey = "{$prefix}{$group}${postfix}{$key}";
24 $result = $this->config->get($configKey, []);
25 if (!is_array($result)) {
26 throw new \UnexpectedValueException($configKey . ' must be a list of settings to apply.');
28 $moreGeneralGroupname = $this->moreGeneralGroupName($group);
29 if ($moreGeneralGroupname) {
30 $result += $this->getWithMerge($key, $moreGeneralGroupname, $prefix, $postfix);