class ExecuteMigration
Same name and namespace in other branches
- 11.x core/modules/migrate/tests/modules/migrate_no_migrate_drupal_test/src/Controller/ExecuteMigration.php \Drupal\migrate_no_migrate_drupal_test\Controller\ExecuteMigration
- 10 core/modules/migrate/tests/modules/migrate_no_migrate_drupal_test/src/Controller/ExecuteMigration.php \Drupal\migrate_no_migrate_drupal_test\Controller\ExecuteMigration
- 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
Custom controller to execute the test migrations.
This controller class is required for the proper functional testing of migration dependencies. Otherwise, the migration directly executed from the functional test would use the functional test's class map and autoloader. The functional test has all the classes available to it but the controller does not.
Hierarchy
- class \Drupal\Core\Controller\ControllerBase implements \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\migrate_no_migrate_drupal_test\Controller\ExecuteMigration extends \Drupal\Core\Controller\ControllerBase
Expanded class hierarchy of ExecuteMigration
1 string reference to 'ExecuteMigration'
- MigrateTestBase::executeMigrations in core/
modules/ migrate/ tests/ src/ Kernel/ MigrateTestBase.php - Executes a set of migrations in dependency order.
File
-
core/
modules/ migrate/ tests/ modules/ migrate_no_migrate_drupal_test/ src/ Controller/ ExecuteMigration.php, line 19
Namespace
Drupal\migrate_no_migrate_drupal_test\ControllerView source
class ExecuteMigration extends ControllerBase {
/**
* Run the node_migration_no_migrate_drupal test migration.
*
* @return array
* A renderable array.
*/
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.',
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.