function ComponentPluginManager::createInstance
Same name in this branch
- 11.x core/lib/Drupal/Core/Theme/ComponentPluginManager.php \Drupal\Core\Theme\ComponentPluginManager::createInstance()
Same name in other branches
- 10 core/modules/sdc/src/ComponentPluginManager.php \Drupal\sdc\ComponentPluginManager::createInstance()
- 10 core/lib/Drupal/Core/Theme/ComponentPluginManager.php \Drupal\Core\Theme\ComponentPluginManager::createInstance()
Creates an instance.
@internal
Throws
\Drupal\sdc\Exception\ComponentNotFoundException
Overrides PluginManagerBase::createInstance
1 call to ComponentPluginManager::createInstance()
- ComponentPluginManager::find in core/
modules/ sdc/ src/ ComponentPluginManager.php - Gets a component for rendering.
File
-
core/
modules/ sdc/ src/ ComponentPluginManager.php, line 99
Class
- ComponentPluginManager
- Defines a plugin manager to deal with sdc.
Namespace
Drupal\sdcCode
public function createInstance($plugin_id, array $configuration = []) : Component {
$configuration['app_root'] = $this->appRoot;
$configuration['enforce_schemas'] = $this->shouldEnforceSchemas($this->definitions[$plugin_id] ?? []);
try {
$instance = parent::createInstance($plugin_id, $configuration);
if (!$instance instanceof Component) {
throw new ComponentNotFoundException(sprintf('Unable to find component "%s" in the component repository.', $plugin_id));
}
return $instance;
} catch (PluginException $e) {
// Cast the PluginNotFound to a more specific exception.
$message = sprintf('Unable to find component "%s" in the component repository. [%s]', $plugin_id, $e->getMessage());
throw new ComponentNotFoundException($message, $e->getCode(), $e);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.