TypedDefinitionEnsuringPluginDiscoveryDecorator.php in Plugin 8.2
File
src/PluginDiscovery/TypedDefinitionEnsuringPluginDiscoveryDecorator.php
View source
<?php
namespace Drupal\plugin\PluginDiscovery;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
use Drupal\plugin\PluginType\PluginTypeInterface;
class TypedDefinitionEnsuringPluginDiscoveryDecorator extends PluginDiscoveryDecorator implements TypedDiscoveryInterface {
protected $pluginType;
public function __construct(PluginTypeInterface $plugin_type, DiscoveryInterface $decorated_discovery = NULL) {
parent::__construct($decorated_discovery ?: $plugin_type
->getPluginManager());
$this->pluginType = $plugin_type;
}
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;
}
}