You are here

public function MigrateUpgradeDrushRunner::configure in Migrate Upgrade 8.2

Same name and namespace in other branches
  1. 8.3 src/MigrateUpgradeDrushRunner.php \Drupal\migrate_upgrade\MigrateUpgradeDrushRunner::configure()
  2. 8 src/MigrateUpgradeDrushRunner.php \Drupal\migrate_upgrade\MigrateUpgradeDrushRunner::configure()

From the provided source information, instantiate the appropriate migrations in the active configuration.

Throws

\Exception

File

src/MigrateUpgradeDrushRunner.php, line 61

Class

MigrateUpgradeDrushRunner

Namespace

Drupal\migrate_upgrade

Code

public function configure() {
  $legacy_db_key = drush_get_option('legacy-db-key');
  if (!empty($legacy_db_key)) {
    $connection = Database::getConnection('default', drush_get_option('legacy-db-key'));
    $this->version = $this
      ->getLegacyDrupalVersion($connection);
    $database_state['key'] = drush_get_option('legacy-db-key');
    $database_state_key = 'migrate_drupal_' . $this->version;
    \Drupal::state()
      ->set($database_state_key, $database_state);
    \Drupal::state()
      ->set('migrate.fallback_state_key', $database_state_key);
  }
  else {
    $db_url = drush_get_option('legacy-db-url');
    $db_spec = drush_convert_db_from_db_url($db_url);
    $db_prefix = drush_get_option('legacy-db-prefix');
    $db_spec['prefix'] = $db_prefix;
    $connection = $this
      ->getConnection($db_spec);
    $this->version = $this
      ->getLegacyDrupalVersion($connection);
    $this
      ->createDatabaseStateSettings($db_spec, $this->version);
  }
  $this->databaseStateKey = 'migrate_drupal_' . $this->version;
  $migrations = $this
    ->getMigrations($this->databaseStateKey, $this->version);
  $this->migrationList = [];
  foreach ($migrations as $migration) {
    $this
      ->applyFilePath($migration);
    $this
      ->expandNodeMigrations($migration);
    $this->migrationList[$migration
      ->id()] = $migration;
  }
}