function DefaultFactory::createInstance

Same name in other branches
  1. 8.9.x core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php \Drupal\Component\Plugin\Factory\DefaultFactory::createInstance()
  2. 10 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 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 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.