You are here

function drush_migrate_get_migrations in Migrate 6.2

Same name and namespace in other branches
  1. 7.2 migrate.drush.inc \drush_migrate_get_migrations()
9 calls to drush_migrate_get_migrations()
drush_migrate_analyze in ./migrate.drush.inc
Analyze the source fields for any passed migrations.
drush_migrate_audit in ./migrate.drush.inc
Display field mappings for a migration.
drush_migrate_fields_destination in ./migrate.drush.inc
drush_migrate_fields_source in ./migrate.drush.inc
drush_migrate_import in ./migrate.drush.inc
Perform import on one or more migrations.

... See full list

File

./migrate.drush.inc, line 860
Drush support for the migrate module

Code

function drush_migrate_get_migrations($args) {
  $migration_objects = migrate_migrations();
  if ($start = drush_get_option('all')) {

    // Handle custom first migration when --all=foo is supplied.
    $seen = $start === TRUE ? TRUE : FALSE;
    foreach ($migration_objects as $name => $migration) {
      if (!$seen && drupal_strtolower($start) . 'migration' == drupal_strtolower($name)) {

        // We found our starting migration. $seen is always TRUE now.
        $seen = TRUE;
      }
      if (!$migration
        ->getEnabled() || !$seen) {

        // This migration is disabled or is before our starting migration.
        unset($migration_objects[$name]);
      }
    }
  }
  elseif ($group = drush_get_option('group')) {
    foreach ($migration_objects as $name => $migration) {
      if (drupal_strtolower($group) != drupal_strtolower($migration
        ->getGroup()
        ->getName()) || !$migration
        ->getEnabled()) {
        unset($migration_objects[$name]);
      }
    }
  }
  else {
    $named_migrations = array();
    foreach (explode(',', $args) as $name) {
      $found = FALSE;
      foreach ($migration_objects as $machine_name => $migration) {
        if (drupal_strtolower($name) == drupal_strtolower($machine_name)) {
          if ($migration
            ->getEnabled()) {
            $named_migrations[$name] = $migration;
            $found = TRUE;
            break;
          }
          else {
            drush_log(dt('Migration !name is disabled', array(
              '!name' => $name,
            )), 'warning');
          }
        }
      }
      if (!$found) {
        drush_log(dt('No migration with machine name !name found', array(
          '!name' => $name,
        )), 'error');
      }
    }
    $migration_objects = $named_migrations;
  }
  return $migration_objects;
}