public function MigratePluginManager::createInstance in Drupal 10
Same name and namespace in other branches
- 8 core/modules/migrate/src/Plugin/MigratePluginManager.php \Drupal\migrate\Plugin\MigratePluginManager::createInstance()
- 9 core/modules/migrate/src/Plugin/MigratePluginManager.php \Drupal\migrate\Plugin\MigratePluginManager::createInstance()
Creates a pre-configured instance of a migration plugin.
A specific createInstance method is necessary to pass the migration on.
Parameters
string $plugin_id: The ID of the plugin being instantiated.
array $configuration: An array of configuration relevant to the plugin instance.
\Drupal\migrate\Plugin\MigrationInterface $migration: The migration context in which the plugin will run.
Return value
object A fully configured plugin instance.
Throws
\Drupal\Component\Plugin\Exception\PluginException If the instance cannot be created, such as if the ID is invalid.
Overrides PluginManagerBase::createInstance
1 method overrides MigratePluginManager::createInstance()
- MigrateDestinationPluginManager::createInstance in core/
modules/ migrate/ src/ Plugin/ MigrateDestinationPluginManager.php - A specific createInstance method is necessary to pass the migration on.
File
- core/
modules/ migrate/ src/ Plugin/ MigratePluginManager.php, line 52
Class
- MigratePluginManager
- Manages migrate plugins.
Namespace
Drupal\migrate\PluginCode
public function createInstance($plugin_id, array $configuration = [], MigrationInterface $migration = NULL) {
$plugin_definition = $this
->getDefinition($plugin_id);
$plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition);
// If the plugin provides a factory method, pass the container to it.
if (is_subclass_of($plugin_class, 'Drupal\\Core\\Plugin\\ContainerFactoryPluginInterface')) {
$plugin = $plugin_class::create(\Drupal::getContainer(), $configuration, $plugin_id, $plugin_definition, $migration);
}
else {
$plugin = new $plugin_class($configuration, $plugin_id, $plugin_definition, $migration);
}
return $plugin;
}