Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / consolidation / config / src / Loader / ConfigProcessor.php
index f5879feb7140c0313f990d74cfdc2c721047c34b..be05289477725819437ebe2dd3918c8f86befed3 100644 (file)
@@ -13,6 +13,7 @@ class ConfigProcessor
 {
     protected $processedConfig = [];
     protected $unprocessedConfig = [];
+    protected $nameOfItemsToMerge = [];
     protected $expander;
 
     public function __construct($expander = null)
@@ -20,6 +21,22 @@ class ConfigProcessor
         $this->expander = $expander ?: new Expander();
     }
 
+    /**
+     * By default, string config items always REPLACE, not MERGE when added
+     * from different sources. This method will allow applications to alter
+     * this behavior for specific items so that strings from multiple sources
+     * will be merged together into an array instead.
+     */
+    public function useMergeStrategyForKeys($itemName)
+    {
+        if (is_array($itemName)) {
+            $this->nameOfItemsToMerge = array_merge($this->nameOfItemsToMerge, $itemName);
+            return $this;
+        }
+        $this->nameOfItemsToMerge[] = $itemName;
+        return $this;
+    }
+
     /**
      * Extend the configuration to be processed with the
      * configuration provided by the specified loader.
@@ -147,7 +164,7 @@ class ConfigProcessor
      */
     protected function reduceOne(array $processed, array $config)
     {
-        return ArrayUtil::mergeRecursiveDistinct($processed, $config);
+        return ArrayUtil::mergeRecursiveSelect($processed, $config, $this->nameOfItemsToMerge);
     }
 
     /**