class PluginDiscoveryDecorator in Plugin 8.2
Decorates plugin discovery.
Hierarchy
- class \Drupal\plugin\PluginDiscovery\PluginDiscoveryDecorator implements CachedDiscoveryInterface, DiscoveryInterface uses DiscoveryTrait, DependencySerializationTrait
Expanded class hierarchy of PluginDiscoveryDecorator
2 files declare their use of PluginDiscoveryDecorator
- PluginDiscoveryDecoratorTest.php in tests/
src/ Unit/ PluginDiscovery/ PluginDiscoveryDecoratorTest.php - PluginManagerDecorator.php in src/
PluginManager/ PluginManagerDecorator.php
File
- src/
PluginDiscovery/ PluginDiscoveryDecorator.php, line 13
Namespace
Drupal\plugin\PluginDiscoveryView source
class PluginDiscoveryDecorator implements DiscoveryInterface, CachedDiscoveryInterface {
use DependencySerializationTrait;
use DiscoveryTrait;
/**
* The decorated discovery.
*
* @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface
*/
protected $decoratedDiscovery;
/**
* The processed plugin definitions.
*
* @var array[]|null
* An array with plugin definitions or NULL if the definitions have not been
* loaded yet.
*
* @see self::getDefinitions()
*/
protected $pluginDefinitions;
/**
* Whether or not to use plugin caching.
*
* @var bool
*/
protected $useCaches = TRUE;
/**
* Constructs a new instance.
*
* @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated_discovery
* The decorated discovery.
*/
public function __construct(DiscoveryInterface $decorated_discovery) {
$this->decoratedDiscovery = $decorated_discovery;
}
/**
* {@inheritdoc}
*/
public function getDefinitions() {
if (is_null($this->pluginDefinitions) || !$this->useCaches) {
$this->pluginDefinitions = $this
->processDecoratedDefinitions($this->decoratedDiscovery
->getDefinitions());
}
return $this->pluginDefinitions;
}
/**
* Processes the definitions from the decorated discovery.
*
* Any changes to the decorated definitions should be performed here.
*
* @param mixed[] $decorated_definitions
* The decorated plugin definitions, keyed by plugin ID.
*
* @return mixed[]
* The processed plugin definitions.
*/
protected function processDecoratedDefinitions(array $decorated_definitions) {
return $decorated_definitions;
}
/**
* {@inheritdoc}
*/
public function useCaches($use_caches = FALSE) {
$this->useCaches = $use_caches;
$decorated_discovery = $this->decoratedDiscovery;
if ($decorated_discovery instanceof CachedDiscoveryInterface) {
$decorated_discovery
->useCaches($use_caches);
}
$this
->clearCachedDefinitions();
}
/**
* {@inheritdoc}
*/
public function clearCachedDefinitions() {
$this->pluginDefinitions = NULL;
$decorated_discovery = $this->decoratedDiscovery;
if ($decorated_discovery instanceof CachedDiscoveryInterface) {
$decorated_discovery
->clearCachedDefinitions();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
DiscoveryTrait:: |
protected | function | Gets a specific plugin definition. | |
DiscoveryTrait:: |
public | function | 3 | |
DiscoveryTrait:: |
public | function | ||
PluginDiscoveryDecorator:: |
protected | property | The decorated discovery. | |
PluginDiscoveryDecorator:: |
protected | property | The processed plugin definitions. | |
PluginDiscoveryDecorator:: |
protected | property | Whether or not to use plugin caching. | |
PluginDiscoveryDecorator:: |
public | function |
Clears static and persistent plugin definition caches. Overrides CachedDiscoveryInterface:: |
|
PluginDiscoveryDecorator:: |
public | function |
Gets the definition of all plugins for this type. Overrides DiscoveryTrait:: |
|
PluginDiscoveryDecorator:: |
protected | function | Processes the definitions from the decorated discovery. | 2 |
PluginDiscoveryDecorator:: |
public | function |
Disable the use of caches. Overrides CachedDiscoveryInterface:: |
|
PluginDiscoveryDecorator:: |
public | function | Constructs a new instance. | 2 |