You are here

public function DefaultFactory::createInstance in Plug 7

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 lib/Drupal/Core/Plugin/Factory/ContainerFactory.php
Creates a pre-configured instance of a plugin.
ReflectionFactory::createInstance in lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php
Creates a pre-configured instance of a plugin.

File

lib/Drupal/Component/Plugin/Factory/DefaultFactory.php, line 56
Contains \Drupal\Component\Plugin\Factory\DefaultFactory.

Class

DefaultFactory
Default plugin factory.

Namespace

Drupal\Component\Plugin\Factory

Code

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);
}