You are here

function drush_migrate_tools_migrate_import in Migrate Tools 8.4

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

Import a migration.

Parameters

string $migration_names: The migration names.

File

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

Code

function drush_migrate_tools_migrate_import($migration_names = '') {
  $group_names = drush_get_option('group');
  $tag_names = drush_get_option('tag');
  $all = drush_get_option('all');

  // Display a depreciation message if "mi" alias is used.
  $args = drush_get_arguments();
  if ($args[0] === 'mi') {
    drush_log('The \'mi\' alias is deprecated and will no longer work with Drush 9. Consider the use of \'mim\' alias instead.', 'warning');
  }
  $options = [];
  if (!$all && !$group_names && !$migration_names && !$tag_names) {
    drush_set_error('MIGRATE_ERROR', dt('You must specify --all, --group, --tag or one or more migration names separated by commas'));
    return;
  }
  $options = [
    'limit',
    'feedback',
    'idlist',
    'idlist-delimiter',
    'update',
    'force',
  ];
  foreach ($options as $option) {
    if (drush_get_option($option)) {
      $options[$option] = drush_get_option($option);
    }
  }
  $migrations = drush_migrate_tools_migration_list($migration_names);
  if (empty($migrations)) {
    drush_log(dt('No migrations found.'), 'error');
  }

  // Take it one group at a time, importing the migrations within each group.
  foreach ($migrations as $group_id => $migration_list) {
    array_walk($migration_list, '_drush_migrate_tools_execute_migration', $options);
  }
}