You are here

public function PluginManagerBase::createInstance in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Component/Plugin/PluginManagerBase.php \Drupal\Component\Plugin\PluginManagerBase::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

17 calls to PluginManagerBase::createInstance()
BreakpointManager::getBreakpointsByGroup in core/modules/breakpoint/src/BreakpointManager.php
Gets breakpoints for the specified group.
CKEditorPluginManager::getButtons in core/modules/ckeditor/src/CKEditorPluginManager.php
Retrieves all available CKEditor buttons, keyed by plugin ID.
CKEditorPluginManager::getEnabledPluginFiles in core/modules/ckeditor/src/CKEditorPluginManager.php
Retrieves enabled plugins' files, keyed by plugin ID.
CKEditorPluginManager::injectPluginSettingsForm in core/modules/ckeditor/src/CKEditorPluginManager.php
Injects the CKEditor plugins settings forms as a vertical tabs subform.
ConfigMapperManager::getMappers in core/modules/config_translation/src/ConfigMapperManager.php
Returns an array of all mappers.

... See full list

11 methods override PluginManagerBase::createInstance()
ArchiverManager::createInstance in core/lib/Drupal/Core/Archiver/ArchiverManager.php
Creates a pre-configured instance of a plugin.
ConditionManager::createInstance in core/lib/Drupal/Core/Condition/ConditionManager.php
Override of Drupal\Component\Plugin\PluginManagerBase::createInstance().
ElementInfoManager::createInstance in core/lib/Drupal/Core/Render/ElementInfoManager.php
FieldTypePluginManager::createInstance in core/lib/Drupal/Core/Field/FieldTypePluginManager.php
Creates a field item, which is not part of an entity or field item list.
FormatterPluginManager::createInstance in core/lib/Drupal/Core/Field/FormatterPluginManager.php
Creates a pre-configured instance of a plugin.

... See full list

File

core/lib/Drupal/Component/Plugin/PluginManagerBase.php, line 76
Contains \Drupal\Component\Plugin\PluginManagerBase.

Class

PluginManagerBase
Base class for plugin managers.

Namespace

Drupal\Component\Plugin

Code

public function createInstance($plugin_id, array $configuration = array()) {

  // If this PluginManager has fallback capabilities catch
  // PluginNotFoundExceptions.
  if ($this instanceof FallbackPluginManagerInterface) {
    try {
      return $this
        ->getFactory()
        ->createInstance($plugin_id, $configuration);
    } catch (PluginNotFoundException $e) {
      $fallback_id = $this
        ->getFallbackPluginId($plugin_id, $configuration);
      return $this
        ->getFactory()
        ->createInstance($fallback_id, $configuration);
    }
  }
  else {
    return $this
      ->getFactory()
      ->createInstance($plugin_id, $configuration);
  }
}