function PluginManagerBase::createInstance

Same name in other branches
  1. 9 core/lib/Drupal/Component/Plugin/PluginManagerBase.php \Drupal\Component\Plugin\PluginManagerBase::createInstance()
  2. 8.9.x core/lib/Drupal/Component/Plugin/PluginManagerBase.php \Drupal\Component\Plugin\PluginManagerBase::createInstance()
  3. 10 core/lib/Drupal/Component/Plugin/PluginManagerBase.php \Drupal\Component\Plugin\PluginManagerBase::createInstance()
12 calls to PluginManagerBase::createInstance()
BreakpointManager::getBreakpointsByGroup in core/modules/breakpoint/src/BreakpointManager.php
CKEditor5PluginManager::getPlugin in core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php
ConfigMapperManager::getMappers in core/modules/config_translation/src/ConfigMapperManager.php
ConstraintManager::create in core/lib/Drupal/Core/Validation/ConstraintManager.php
Creates a validation constraint.
ContextualLinkManager::getContextualLinksArrayByGroup in core/lib/Drupal/Core/Menu/ContextualLinkManager.php
Gets the contextual links prepared as expected by links.html.twig.

... See full list

15 methods override PluginManagerBase::createInstance()
ArchiverManager::createInstance in core/lib/Drupal/Core/Archiver/ArchiverManager.php
ComponentPluginManager::createInstance in core/modules/sdc/src/ComponentPluginManager.php
Creates an instance.
ComponentPluginManager::createInstance in core/lib/Drupal/Core/Theme/ComponentPluginManager.php
Creates an instance.
ConditionManager::createInstance in core/lib/Drupal/Core/Condition/ConditionManager.php
ConfigActionManager::createInstance in core/lib/Drupal/Core/Config/Action/ConfigActionManager.php

... See full list

File

core/lib/Drupal/Component/Plugin/PluginManagerBase.php, line 71

Class

PluginManagerBase
Base class for plugin managers.

Namespace

Drupal\Component\Plugin

Code

public function createInstance($plugin_id, array $configuration = []) {
    // If this PluginManager has fallback capabilities catch
    // PluginNotFoundExceptions.
    if ($this instanceof FallbackPluginManagerInterface) {
        try {
            return $this->getFactory()
                ->createInstance($plugin_id, $configuration);
        } catch (PluginNotFoundException) {
            return $this->handlePluginNotFound($plugin_id, $configuration);
        }
    }
    else {
        return $this->getFactory()
            ->createInstance($plugin_id, $configuration);
    }
}

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