public function DefaultFactory::createInstance in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php \Drupal\Component\Plugin\Factory\DefaultFactory::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.
Throws
\Drupal\Component\Plugin\Exception\PluginException If the instance cannot be created, such as if the ID is invalid.
Overrides FactoryInterface::createInstance
2 methods override DefaultFactory::createInstance()
- ContainerFactory::createInstance in core/
lib/ Drupal/ Core/ Plugin/ Factory/ ContainerFactory.php - Creates a pre-configured instance of a plugin.
- ReflectionFactory::createInstance in core/
lib/ Drupal/ Component/ Plugin/ Factory/ ReflectionFactory.php - Creates a pre-configured instance of a plugin.
File
- core/
lib/ Drupal/ Component/ Plugin/ Factory/ DefaultFactory.php, line 56 - Contains \Drupal\Component\Plugin\Factory\DefaultFactory.
Class
- DefaultFactory
- Default plugin factory.
Namespace
Drupal\Component\Plugin\FactoryCode
public function createInstance($plugin_id, array $configuration = array()) {
$plugin_definition = $this->discovery
->getDefinition($plugin_id);
$plugin_class = static::getPluginClass($plugin_id, $plugin_definition, $this->interface);
return new $plugin_class($configuration, $plugin_id, $plugin_definition);
}