You are here

function backup_migrate_destination::create in Backup and Migrate 7.2

Same name and namespace in other branches
  1. 8.2 includes/destinations.inc \backup_migrate_destination::create()
  2. 6.2 includes/destinations.inc \backup_migrate_destination::create()

Create a new destination of the correct type.

Overrides backup_migrate_item::create

File

includes/destinations.inc, line 932

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;
}