You are here

function drush_migrate_tools_migrate_stop in Migrate Tools 8.2

Same name and namespace in other branches
  1. 8 migrate_tools.drush.inc \drush_migrate_tools_migrate_stop()
  2. 8.3 migrate_tools.drush.inc \drush_migrate_tools_migrate_stop()
  3. 8.4 migrate_tools.drush.inc \drush_migrate_tools_migrate_stop()

Parameters

string $migration_id:

File

./migrate_tools.drush.inc, line 322
Command-line tools to aid performing and developing migrations.

Code

function drush_migrate_tools_migrate_stop($migration_id = '') {

  /** @var MigrationInterface $migration */
  $migration = \Drupal::service('plugin.manager.migration')
    ->createInstance($migration_id);
  if ($migration) {
    $status = $migration
      ->getStatus();
    switch ($status) {
      case MigrationInterface::STATUS_IDLE:
        drush_log(dt('Migration @id is idle', [
          '@id' => $migration_id,
        ]), 'warning');
        break;
      case MigrationInterface::STATUS_DISABLED:
        drush_log(dt('Migration @id is disabled', [
          '@id' => $migration_id,
        ]), 'warning');
        break;
      case MigrationInterface::STATUS_STOPPING:
        drush_log(dt('Migration @id is already stopping', [
          '@id' => $migration_id,
        ]), 'warning');
        break;
      default:
        $migration
          ->interruptMigration(MigrationInterface::RESULT_STOPPED);
        drush_log(dt('Migration @id requested to stop', [
          '@id' => $migration_id,
        ]), 'success');
        break;
    }
  }
  else {
    drush_log(dt('Migration @id does not exist', [
      '@id' => $migration_id,
    ]), 'error');
  }
}