function _sitealias_array_merge

8.0.x sitealias.inc _sitealias_array_merge($site_alias_a, $site_alias_b)
6.x sitealias.inc _sitealias_array_merge($site_alias_a, $site_alias_b)
7.x sitealias.inc _sitealias_array_merge($site_alias_a, $site_alias_b)
5.x sitealias.inc _sitealias_array_merge($site_alias_a, $site_alias_b)
master sitealias.inc _sitealias_array_merge($site_alias_a, $site_alias_b)

Merges two site aliases.

array_merge_recursive is too much; we only want to run array_merge on the common top-level keys of the array.

Parameters

array $site_alias_a: A site alias array.

array $site_alias_b: A site alias array.

Return value

A site alias array where the keys from $site_alias_a are overwritten by the keys from $site_alias_b.

3 calls to _sitealias_array_merge()
saUnitCase::testArrayMerge in tests/siteAliasUnitTest.php
Tests _sitealias_array_merge().
_drush_sitealias_find_and_load_alias_from_file in includes/sitealias.inc
_drush_sitealias_find_and_load_all_aliases in includes/sitealias.inc
Worker function called by _drush_sitealias_load_alias and drush_sitealias_load_all. Traverses the alias search path and finds the specified alias record.

File

includes/sitealias.inc, line 771
The site alias API.

Code

function _sitealias_array_merge($site_alias_a, $site_alias_b) {
  $result = $site_alias_a;

  foreach ($site_alias_b as $key => $value) {
    if (is_array($value) && array_key_exists($key, $result)) {
      $result[$key] = array_merge($result[$key], $value);
    }
    else {
      $result[$key] = $value;
    }
  }

  return $result;
}