function ExecuteMigration::execute

Same name in other branches
  1. 9 core/modules/migrate/tests/modules/migrate_no_migrate_drupal_test/src/Controller/ExecuteMigration.php \Drupal\migrate_no_migrate_drupal_test\Controller\ExecuteMigration::execute()
  2. 8.9.x core/modules/migrate/tests/modules/migrate_no_migrate_drupal_test/src/Controller/ExecuteMigration.php \Drupal\migrate_no_migrate_drupal_test\Controller\ExecuteMigration::execute()
  3. 10 core/modules/migrate/tests/modules/migrate_no_migrate_drupal_test/src/Controller/ExecuteMigration.php \Drupal\migrate_no_migrate_drupal_test\Controller\ExecuteMigration::execute()

Run the node_migration_no_migrate_drupal test migration.

Return value

array A renderable array.

1 string reference to 'ExecuteMigration::execute'
migrate_no_migrate_drupal_test.routing.yml in core/modules/migrate/tests/modules/migrate_no_migrate_drupal_test/migrate_no_migrate_drupal_test.routing.yml
core/modules/migrate/tests/modules/migrate_no_migrate_drupal_test/migrate_no_migrate_drupal_test.routing.yml

File

core/modules/migrate/tests/modules/migrate_no_migrate_drupal_test/src/Controller/ExecuteMigration.php, line 29

Class

ExecuteMigration
Custom controller to execute the test migrations.

Namespace

Drupal\migrate_no_migrate_drupal_test\Controller

Code

public function execute() {
    $migration_plugin_manager = \Drupal::service('plugin.manager.migration');
    $definitions = $migration_plugin_manager->getDefinitions();
    if ($definitions['node_migration_no_migrate_drupal']['label'] !== 'Node Migration No Migrate Drupal') {
        throw new InvalidPluginDefinitionException('node_migration_no_migrate_drupal');
    }
    $migrations = $migration_plugin_manager->createInstances('node_migration_no_migrate_drupal');
    $result = (new MigrateExecutable($migrations['node_migration_no_migrate_drupal']))->import();
    if ($result !== MigrationInterface::RESULT_COMPLETED) {
        throw new \RuntimeException('Migration failed');
    }
    return [
        '#type' => 'markup',
        '#markup' => 'Migration was successful.',
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.