You are here

function _drush_migrate_tools_execute_migration in Migrate Tools 8.2

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

Executes a single migration. If the --execute-dependencies option was given, the migration's dependencies will also be executed first.

Parameters

\Drupal\migrate\Plugin\MigrationInterface $migration: The migration to execute.

string $migration_id: The migration ID (not used, just an artifact of array_walk()).

array $options: Additional options for the migration.

1 string reference to '_drush_migrate_tools_execute_migration'
drush_migrate_tools_migrate_import in ./migrate_tools.drush.inc

File

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

Code

function _drush_migrate_tools_execute_migration(MigrationInterface $migration, $migration_id, array $options = []) {
  $log = new DrushLogMigrateMessage();
  if (drush_get_option('execute-dependencies')) {
    if ($required_IDS = $migration
      ->get('requirements')) {
      $manager = \Drupal::service('plugin.manager.config_entity_migration');
      $required_migrations = $manager
        ->createInstances($required_IDS);
      $dependency_options = array_merge($options, [
        'is_dependency' => TRUE,
      ]);
      array_walk($required_migrations, __FUNCTION__, $dependency_options);
    }
  }
  if (!empty($options['force'])) {
    $migration
      ->set('requirements', []);
  }
  if (!empty($options['update'])) {
    $migration
      ->getIdMap()
      ->prepareUpdate();
  }
  $executable = new MigrateExecutable($migration, $log, $options);

  // drush_op() provides --simulate support
  drush_op(array(
    $executable,
    'import',
  ));
}