You are here

function backup_migrate_location::create in Backup and Migrate 8.3

Same name and namespace in other branches
  1. 6.3 includes/locations.inc \backup_migrate_location::create()
  2. 7.3 includes/locations.inc \backup_migrate_location::create()

Create a new location of the correct type.

Overrides backup_migrate_item::create

File

includes/locations.inc, line 351

Class

backup_migrate_location
A base class for creating locations.

Code

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

  // Get the type passed in in the params, or if none, check the url for a valid type name.
  // This is to allow new location type to be specified in the path.
  $location_type = !empty($params['subtype']) ? $params['subtype'] : NULL;
  if ($location_type && ($type = @$types[$location_type])) {

    // Include the necessary file if specified by the type.
    if (!empty($type['file'])) {
      require_once './' . $type['file'];
    }
    $out = new $type['class']($params + array(
      'subtype' => $location_type,
    ));
  }
  if (empty($out)) {
    $out = parent::create($params);
  }
  return $out;
}