function DerivativeDiscoveryDecorator::getDerivatives
Same name in other branches
- 9 core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator::getDerivatives()
- 8.9.x core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator::getDerivatives()
- 11.x core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator::getDerivatives()
Adds derivatives to a list of plugin definitions.
This should be called by the class extending this in DiscoveryInterface::getDefinitions().
1 call to DerivativeDiscoveryDecorator::getDerivatives()
- DerivativeDiscoveryDecorator::getDefinitions in core/
lib/ Drupal/ Component/ Plugin/ Discovery/ DerivativeDiscoveryDecorator.php
File
-
core/
lib/ Drupal/ Component/ Plugin/ Discovery/ DerivativeDiscoveryDecorator.php, line 96
Class
- DerivativeDiscoveryDecorator
- Base class providing the tools for a plugin discovery to be derivative aware.
Namespace
Drupal\Component\Plugin\DiscoveryCode
protected function getDerivatives(array $base_plugin_definitions) {
$plugin_definitions = [];
foreach ($base_plugin_definitions as $base_plugin_id => $plugin_definition) {
$deriver = $this->getDeriver($base_plugin_id, $plugin_definition);
if ($deriver) {
$derivative_definitions = $deriver->getDerivativeDefinitions($plugin_definition);
foreach ($derivative_definitions as $derivative_id => $derivative_definition) {
$plugin_id = $this->encodePluginId($base_plugin_id, $derivative_id);
// Use this definition as defaults if a plugin already defined
// itself as this derivative.
if ($derivative_id && isset($base_plugin_definitions[$plugin_id])) {
$derivative_definition = $this->mergeDerivativeDefinition($base_plugin_definitions[$plugin_id], $derivative_definition);
}
$plugin_definitions[$plugin_id] = $derivative_definition;
}
}
elseif (!isset($plugin_definitions[$base_plugin_id])) {
$plugin_definitions[$base_plugin_id] = $plugin_definition;
}
}
return $plugin_definitions;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.