Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / consolidation / config / src / Util / ConfigMerge.php
diff --git a/vendor/consolidation/config/src/Util/ConfigMerge.php b/vendor/consolidation/config/src/Util/ConfigMerge.php
new file mode 100644 (file)
index 0000000..65fccf7
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+namespace Consolidation\Config\Util;
+
+/**
+ * Works like 'getWithFallback', but merges results from all applicable
+ * groups. Settings from most specific group take precedence.
+ */
+class ConfigMerge extends ConfigGroup
+{
+    /**
+     * @inheritdoc
+     */
+    public function get($key)
+    {
+        return $this->getWithMerge($key, $this->group, $this->prefix, $this->postfix);
+    }
+
+    /**
+     * Merge available configuration from each configuration group.
+     */
+    public function getWithMerge($key, $group, $prefix = '', $postfix = '.')
+    {
+        $configKey = "{$prefix}{$group}${postfix}{$key}";
+        $result = $this->config->get($configKey, []);
+        if (!is_array($result)) {
+            throw new \UnexpectedValueException($configKey . ' must be a list of settings to apply.');
+        }
+        $moreGeneralGroupname = $this->moreGeneralGroupName($group);
+        if ($moreGeneralGroupname) {
+            $result += $this->getWithMerge($key, $moreGeneralGroupname, $prefix, $postfix);
+        }
+        return $result;
+    }
+}