You are here

class PluginManagerDecorator in Plugin 8.2

Provides a plugin manager decorator.

Hierarchy

Expanded class hierarchy of PluginManagerDecorator

2 files declare their use of PluginManagerDecorator
AdvancedPluginSelectorBasePluginSelectorForm.php in tests/modules/plugin_test_helper/src/AdvancedPluginSelectorBasePluginSelectorForm.php
PluginManagerDecoratorTest.php in tests/src/Unit/PluginManager/PluginManagerDecoratorTest.php

File

src/PluginManager/PluginManagerDecorator.php, line 13

Namespace

Drupal\plugin\PluginManager
View source
class PluginManagerDecorator extends PluginDiscoveryDecorator implements PluginManagerInterface {

  /**
   * The decorated plugin factory.
   *
   * @var \Drupal\Component\Plugin\PluginManagerInterface
   */
  protected $decoratedFactory;

  /**
   * Creates a new instance.
   *
   * @param \Drupal\Component\Plugin\PluginManagerInterface $plugin_manager
   *   The decorated plugin manager.
   * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface|null $discovery
   *   A plugin discovery to use instead of the decorated plugin manager, or
   *   NULL to use the decorated plugin manager.
   */
  public function __construct(PluginManagerInterface $plugin_manager, DiscoveryInterface $discovery = NULL) {
    $this->decoratedDiscovery = $discovery ? $discovery : $plugin_manager;
    $this->decoratedFactory = $plugin_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function createInstance($plugin_id, array $configuration = []) {
    if ($this
      ->hasDefinition($plugin_id)) {
      return $this->decoratedFactory
        ->createInstance($plugin_id, $configuration);
    }
    else {
      throw new PluginNotFoundException($plugin_id);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getInstance(array $options) {
    throw new \BadMethodCallException('This method is not supported. See https://www.drupal.org/node/1894130.');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
DiscoveryTrait::doGetDefinition protected function Gets a specific plugin definition.
DiscoveryTrait::getDefinition public function 3
DiscoveryTrait::hasDefinition public function
PluginDiscoveryDecorator::$decoratedDiscovery protected property The decorated discovery.
PluginDiscoveryDecorator::$pluginDefinitions protected property The processed plugin definitions.
PluginDiscoveryDecorator::$useCaches protected property Whether or not to use plugin caching.
PluginDiscoveryDecorator::clearCachedDefinitions public function Clears static and persistent plugin definition caches. Overrides CachedDiscoveryInterface::clearCachedDefinitions
PluginDiscoveryDecorator::getDefinitions public function Gets the definition of all plugins for this type. Overrides DiscoveryTrait::getDefinitions
PluginDiscoveryDecorator::processDecoratedDefinitions protected function Processes the definitions from the decorated discovery. 2
PluginDiscoveryDecorator::useCaches public function Disable the use of caches. Overrides CachedDiscoveryInterface::useCaches
PluginManagerDecorator::$decoratedFactory protected property The decorated plugin factory.
PluginManagerDecorator::createInstance public function Creates a pre-configured instance of a plugin. Overrides FactoryInterface::createInstance
PluginManagerDecorator::getInstance public function Gets a preconfigured instance of a plugin. Overrides MapperInterface::getInstance
PluginManagerDecorator::__construct public function Creates a new instance. Overrides PluginDiscoveryDecorator::__construct