You are here

protected function MigrationDefinitionCreator::arrayMergeRecursiveDistinct in GatherContent 8.5

Merge arrays recursively and override existing values.

1 call to MigrationDefinitionCreator::arrayMergeRecursiveDistinct()
MigrationDefinitionCreator::getGroupedDefinitions in src/MigrationDefinitionCreator.php
Return the concatenated definitions for the given template.

File

src/MigrationDefinitionCreator.php, line 755

Class

MigrationDefinitionCreator
Create dynamic migration definitions.

Namespace

Drupal\gathercontent

Code

protected function arrayMergeRecursiveDistinct(array &$array1, array &$array2) {
  $merged = $array1;
  foreach ($array2 as $key => &$value) {
    if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
      $merged[$key] = $this
        ->arrayMergeRecursiveDistinct($merged[$key], $value);
    }
    else {
      $merged[$key] = $value;
    }
  }
  return $merged;
}