You are here

class LimitedPluginDiscoveryDecorator in Plugin 8.2

Provides a filtered plugin manager.

Hierarchy

Expanded class hierarchy of LimitedPluginDiscoveryDecorator

2 files declare their use of LimitedPluginDiscoveryDecorator
AdvancedPluginSelectorBasePluginSelectorForm.php in tests/modules/plugin_test_helper/src/AdvancedPluginSelectorBasePluginSelectorForm.php
LimitedPluginDiscoveryDecoratorTest.php in tests/src/Unit/PluginDiscovery/LimitedPluginDiscoveryDecoratorTest.php

File

src/PluginDiscovery/LimitedPluginDiscoveryDecorator.php, line 8

Namespace

Drupal\plugin\PluginDiscovery
View source
class LimitedPluginDiscoveryDecorator extends PluginDiscoveryDecorator implements LimitedPluginDiscoveryInterface {

  /**
   * The discovery limit.
   *
   * @var string[]|null
   *   An array of plugin IDs or NULL if the limit is not set.
   */
  protected $discoveryLimit;

  /**
   * {@inheritdoc}
   */
  protected function processDecoratedDefinitions(array $decorated_definitions) {
    if (is_array($this->discoveryLimit)) {
      return array_intersect_key($decorated_definitions, array_flip($this->discoveryLimit));
    }
    else {
      return $decorated_definitions;
    }
  }

  /**
   * {@inheritdoc}
   */
  public function setDiscoveryLimit(array $plugin_ids) {
    $this->discoveryLimit = $plugin_ids;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function resetDiscoveryLimit() {
    $this->discoveryLimit = NULL;
    $this
      ->clearCachedDefinitions();
    return $this;
  }

}

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
LimitedPluginDiscoveryDecorator::$discoveryLimit protected property The discovery limit.
LimitedPluginDiscoveryDecorator::processDecoratedDefinitions protected function Processes the definitions from the decorated discovery. Overrides PluginDiscoveryDecorator::processDecoratedDefinitions
LimitedPluginDiscoveryDecorator::resetDiscoveryLimit public function Resets the discovery limit. Overrides LimitedPluginDiscoveryInterface::resetDiscoveryLimit
LimitedPluginDiscoveryDecorator::setDiscoveryLimit public function Limits the plugins to discover. Overrides LimitedPluginDiscoveryInterface::setDiscoveryLimit
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::useCaches public function Disable the use of caches. Overrides CachedDiscoveryInterface::useCaches
PluginDiscoveryDecorator::__construct public function Constructs a new instance. 2