public function ExecuteMigration::execute in Drupal 9
Same name and namespace in other branches
- 8 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 27
Class
- ExecuteMigration
- Custom controller to execute the test migrations.
Namespace
Drupal\migrate_no_migrate_drupal_test\ControllerCode
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('');
$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.',
];
}