You are here

class TypedDefinitionEnsuringPluginDiscoveryDecorator in Plugin 8.2

Provides plugin discovery that ensures all definitions implement \Drupal\Component\Plugin\PluginDefinitionInterface.

Hierarchy

Expanded class hierarchy of TypedDefinitionEnsuringPluginDiscoveryDecorator

3 files declare their use of TypedDefinitionEnsuringPluginDiscoveryDecorator
ListPlugins.php in src/Controller/ListPlugins.php
PluginSelectorBase.php in src/Plugin/Plugin/PluginSelector/PluginSelectorBase.php
TypedDefinitionEnsuringPluginDiscoveryDecoratorTest.php in tests/src/Unit/PluginDiscovery/TypedDefinitionEnsuringPluginDiscoveryDecoratorTest.php

File

src/PluginDiscovery/TypedDefinitionEnsuringPluginDiscoveryDecorator.php, line 12

Namespace

Drupal\plugin\PluginDiscovery
View source
class TypedDefinitionEnsuringPluginDiscoveryDecorator extends PluginDiscoveryDecorator implements TypedDiscoveryInterface {

  /**
   * The type of the plugin definitions to decorate.
   *
   * @var \Drupal\plugin\PluginType\PluginTypeInterface
   */
  protected $pluginType;

  /**
   * Constructs a new instance.
   *
   * @param \Drupal\plugin\PluginType\PluginTypeInterface $plugin_type
   *   The plugin type of which to decorate definitions.
   * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface|NULL $decorated_discovery
   *   The decorated discovery, or NULL to use the plugin type's default
   *   discovery.
   */
  public function __construct(PluginTypeInterface $plugin_type, DiscoveryInterface $decorated_discovery = NULL) {
    parent::__construct($decorated_discovery ?: $plugin_type
      ->getPluginManager());
    $this->pluginType = $plugin_type;
  }

  /**
   * {@inheritdoc}
   */
  public function processDecoratedDefinitions(array $decorated_plugin_definitions) {
    $processed_plugin_definitions = [];
    foreach ($decorated_plugin_definitions as $plugin_id => $decorated_plugin_definition) {
      $processed_plugin_definitions[$plugin_id] = $this->pluginType
        ->ensureTypedPluginDefinition($decorated_plugin_definition);
    }
    return $processed_plugin_definitions;
  }

}

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::useCaches public function Disable the use of caches. Overrides CachedDiscoveryInterface::useCaches
TypedDefinitionEnsuringPluginDiscoveryDecorator::$pluginType protected property The type of the plugin definitions to decorate.
TypedDefinitionEnsuringPluginDiscoveryDecorator::processDecoratedDefinitions public function Processes the definitions from the decorated discovery. Overrides PluginDiscoveryDecorator::processDecoratedDefinitions
TypedDefinitionEnsuringPluginDiscoveryDecorator::__construct public function Constructs a new instance. Overrides PluginDiscoveryDecorator::__construct