You are here

public function MigrateManifestCommands::manifest in Migrate Manifest 8

Same name and namespace in other branches
  1. 8.2 src/Commands/MigrateManifestCommands.php \Drupal\migrate_manifest\Commands\MigrateManifestCommands::manifest()
  2. 3.x src/Commands/MigrateManifestCommands.php \Drupal\migrate_manifest\Commands\MigrateManifestCommands::manifest()

Execute the migrations as specified in a manifest file.

@command migrate:manifest

@option legacy-db-url A database url to use for migrations. @option legacy-db-prefix A prefix to use for tables through the migration connection. @option legacy-db-key A database connection key from settings.php. Use as an alternative to legacy-db-url @option update In addition to processing unprocessed items from the source, update previously-imported items with the current data @option force Force an operation to run, even if all dependencies are not satisfied @validate-module-enabled migrate_manifest @aliases migrate-manifest2,mm,migrate-manifest

Parameters

$manifest The path to the manifest file:

File

src/Commands/MigrateManifestCommands.php, line 39

Class

MigrateManifestCommands
Drush 9 Migrate manifest command.

Namespace

Drupal\migrate_manifest\Commands

Code

public function manifest($manifest, $options = [
  'legacy-db-url' => NULL,
  'legacy-db-prefix' => NULL,
  'legacy-db-key' => NULL,
  'update' => NULL,
  'force' => NULL,
]) {
  try {
    $migration_manager = \Drupal::service('plugin.manager.migration');
    $manifest_runner = new MigrateManifest($migration_manager, $this
      ->logger(), $options['force'], $options['update']);
    MigrateManifest::setDbState($options['legacy-db-key'], $options['legacy-db-url'], $options['legacy-db-prefix']);
    $manifest_runner
      ->import($manifest);
  } catch (\Exception $e) {
    $this
      ->logger()
      ->error($e
      ->getMessage());
  }
  $process = Drush::drush($this
    ->siteAliasManager()
    ->getSelf(), 'cache-rebuild');
  $process
    ->mustRun();
}