function backup_migrate_destination::create

nittany7 destinations.inc backup_migrate_destination::create($params = array())
mooc7 destinations.inc backup_migrate_destination::create($params = array())

Create a new destination of the correct type.

Overrides backup_migrate_item::create

File

modules/contrib/backup_migrate/includes/destinations.inc, line 932
All of the destination handling code needed for Backup and Migrate.

Class

backup_migrate_destination
A base class for creating destinations.

Code

function create($params = array()) {
  $out = NULL;
  $types = backup_migrate_get_destination_types();

  // Get the type passed in in the params, or if none, check the url for a valid type name.
  // This is to allow new destination type to be specified in the path.
  $destination_type = !empty($params['type']) ? $params['type'] : arg(BACKUP_MIGRATE_MENU_DEPTH + 3);

  if ($destination_type && ($type = @$types[$destination_type])) {
    // Include the necessary file if specified by the type.
    if (!empty($type['file'])) {
      require_once './' . $type['file'];
    }
    $out = new $type['class']($params + array('destination_type' => $destination_type));
  }
  if (empty($out)) {
    $out = new backup_migrate_destination();
  }
  return $out;
}