class TypedDefinitionEnsuringPluginDiscoveryDecorator in Plugin 8.2
Provides plugin discovery that ensures all definitions implement \Drupal\Component\Plugin\PluginDefinitionInterface.
Hierarchy
- class \Drupal\plugin\PluginDiscovery\PluginDiscoveryDecorator implements CachedDiscoveryInterface, DiscoveryInterface uses DiscoveryTrait, DependencySerializationTrait
- class \Drupal\plugin\PluginDiscovery\TypedDefinitionEnsuringPluginDiscoveryDecorator implements TypedDiscoveryInterface
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\PluginDiscoveryView 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;
}
}