function PluginManagerBase::createInstance
Same name and namespace in other branches
- 11.x core/lib/Drupal/Component/Plugin/PluginManagerBase.php \Drupal\Component\Plugin\PluginManagerBase::createInstance()
- 10 core/lib/Drupal/Component/Plugin/PluginManagerBase.php \Drupal\Component\Plugin\PluginManagerBase::createInstance()
- 8.9.x core/lib/Drupal/Component/Plugin/PluginManagerBase.php \Drupal\Component\Plugin\PluginManagerBase::createInstance()
Creates a pre-configured instance of a plugin.
Parameters
string $plugin_id: The ID of the plugin being instantiated.
array $configuration: An array of configuration relevant to the plugin instance.
Return value
object A fully configured plugin instance.
Overrides FactoryInterface::createInstance
2 calls to PluginManagerBase::createInstance()
- ConfigMapperManager::getMappers in core/
modules/ config_translation/ src/ ConfigMapperManager.php - Returns an array of all mappers.
- SectionStorageManager::loadEmpty in core/
modules/ layout_builder/ src/ SectionStorage/ SectionStorageManager.php - Loads a section storage with no associated section list.
1 method overrides PluginManagerBase::createInstance()
- QueueWorkerManager::createInstance in core/
lib/ Drupal/ Core/ Queue/ QueueWorkerManager.php
File
-
core/
lib/ Drupal/ Component/ Plugin/ PluginManagerBase.php, line 71
Class
- PluginManagerBase
- Base class for plugin managers.
Namespace
Drupal\Component\PluginCode
public function createInstance($plugin_id, array $configuration = []) {
// If this PluginManager has fallback capabilities catch
// PluginNotFoundExceptions.
if ($this instanceof FallbackPluginManagerInterface) {
try {
return $this->getFactory()
->createInstance($plugin_id, $configuration);
} catch (PluginNotFoundException $e) {
return $this->handlePluginNotFound($plugin_id, $configuration);
}
}
else {
return $this->getFactory()
->createInstance($plugin_id, $configuration);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.