You are here

function backup_migrate_item::_merge_defaults in Backup and Migrate 6.2

Same name and namespace in other branches
  1. 8.3 includes/crud.inc \backup_migrate_item::_merge_defaults()
  2. 6.3 includes/crud.inc \backup_migrate_item::_merge_defaults()
  3. 7.3 includes/crud.inc \backup_migrate_item::_merge_defaults()

Merge parameters with the given defaults.

Works like array_merge_recursive, but it doesn't turn scalar values into arrays.

1 call to backup_migrate_item::_merge_defaults()
backup_migrate_item::__construct in includes/crud.inc
Constructor, set the basic info pulled from the db or generated programatically.

File

includes/crud.inc, line 243
CRUD functions for backup and migrate types (schedules, profiles etc.).

Class

backup_migrate_item
A base class for items which can be stored in the database, listed, edited, deleted etc.

Code

function _merge_defaults($params, $defaults) {
  foreach ($defaults as $key => $val) {
    if (!isset($params[$key])) {
      $params[$key] = $val;
    }
    else {
      if (is_array($params[$key])) {
        $params[$key] = $this
          ->_merge_defaults($params[$key], $val);
      }
    }
  }
  return $params;
}