function DefaultFactory::createInstance

Same name in other branches
  1. 9 core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php \Drupal\Component\Plugin\Factory\DefaultFactory::createInstance()
  2. 8.9.x core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php \Drupal\Component\Plugin\Factory\DefaultFactory::createInstance()
  3. 11.x core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php \Drupal\Component\Plugin\Factory\DefaultFactory::createInstance()

Overrides FactoryInterface::createInstance

2 methods override DefaultFactory::createInstance()
ContainerFactory::createInstance in core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php
Creates a plugin instance based on the provided ID and configuration.
ReflectionFactory::createInstance in core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php
Creates a plugin instance based on the provided ID and configuration.

File

core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php, line 52

Class

DefaultFactory
Default plugin factory.

Namespace

Drupal\Component\Plugin\Factory

Code

public function createInstance($plugin_id, array $configuration = []) {
    $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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.