class PluginCollectionItemDeriver in Plugin 8.2
Derives plugin collection field items.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\plugin\Plugin\Field\FieldType\PluginCollectionItemDeriver implements ContainerDeriverInterface
Expanded class hierarchy of PluginCollectionItemDeriver
1 file declares its use of PluginCollectionItemDeriver
- PluginCollectionItemDeriverTest.php in tests/
src/ Unit/ Plugin/ Field/ FieldType/ PluginCollectionItemDeriverTest.php
File
- src/
Plugin/ Field/ FieldType/ PluginCollectionItemDeriver.php, line 13
Namespace
Drupal\plugin\Plugin\Field\FieldTypeView source
class PluginCollectionItemDeriver extends DeriverBase implements ContainerDeriverInterface {
/**
* The plugin type manager.
*
* @var \Drupal\plugin\PluginType\PluginTypeManagerInterface
*/
protected $pluginTypeManager;
/**
* Constructs a new class instance.
*
* @param \Drupal\plugin\PluginTypeManagerInterface
* The plugin type manager.
*/
public function __construct(PluginTypeManagerInterface $plugin_type_manager) {
$this->pluginTypeManager = $plugin_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('plugin.plugin_type_manager'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
foreach ($this->pluginTypeManager
->getPluginTypes() as $plugin_type) {
if ($plugin_type
->isFieldType()) {
$this->derivatives[$plugin_type
->getId()] = [
'description' => $plugin_type
->getDescription(),
'label' => $plugin_type
->getLabel(),
'plugin_type_id' => $plugin_type
->getId(),
] + $base_plugin_definition;
}
}
return parent::getDerivativeDefinitions($base_plugin_definition);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
PluginCollectionItemDeriver:: |
protected | property | The plugin type manager. | |
PluginCollectionItemDeriver:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
PluginCollectionItemDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
PluginCollectionItemDeriver:: |
public | function | Constructs a new class instance. |