You are here

function drush_hosting_migrate_pre_hosting_task in Hosting 7.4

Same name and namespace in other branches
  1. 5 migrate/hosting_migrate.drush.inc \drush_hosting_migrate_pre_hosting_task()
  2. 6.2 migrate/hosting_migrate.drush.inc \drush_hosting_migrate_pre_hosting_task()
  3. 7.3 migrate/hosting_migrate.drush.inc \drush_hosting_migrate_pre_hosting_task()

@file Implement drush hooks for the hosting migrate module.

File

migrate/hosting_migrate.drush.inc, line 7
Implement drush hooks for the hosting migrate module.

Code

function drush_hosting_migrate_pre_hosting_task($task) {
  $task =& drush_get_context('HOSTING_TASK');
  if ($task->ref->type == 'site' && $task->task_type == 'migrate') {
    $platform = node_load($task->task_args['target_platform']);
    $task->args[2] = hosting_context_name($platform->nid);
    $site = $task->ref;
    if (hosting_site_get_domain($site->title) != hosting_site_get_domain($task->task_args['new_uri'])) {
      $task->args[3] = '@' . hosting_site_get_domain($task->task_args['new_uri']);
    }
    if ($site->db_server != $task->task_args['new_db_server']) {
      $task->options['new_db_server'] = hosting_context_name($task->task_args['new_db_server']);
    }
    $profile_instance = _hosting_migrate_get_target_profile_name($task);
    if (is_object($profile_instance) && isset($profile_instance->short_name)) {
      $task->options['profile'] = $profile_instance->short_name;
    }
    else {
      drush_set_error("HOSTING_NO_VALID_PROFILE", dt("There are no valid install profiles on the target platform to migrate to"));
    }
  }
}