function DerivativeDiscoveryDecorator::mergeDerivativeDefinition
Same name in other branches
- 8.9.x core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator::mergeDerivativeDefinition()
- 10 core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator::mergeDerivativeDefinition()
- 11.x core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator::mergeDerivativeDefinition()
Merges a base and derivative definition, taking into account empty values.
Parameters
array $base_plugin_definition: The base plugin definition.
array $derivative_definition: The derivative plugin definition.
Return value
array The merged definition.
2 calls to DerivativeDiscoveryDecorator::mergeDerivativeDefinition()
- DerivativeDiscoveryDecorator::getDefinition in core/
lib/ Drupal/ Component/ Plugin/ Discovery/ DerivativeDiscoveryDecorator.php - DerivativeDiscoveryDecorator::getDerivatives in core/
lib/ Drupal/ Component/ Plugin/ Discovery/ DerivativeDiscoveryDecorator.php - Adds derivatives to a list of plugin definitions.
File
-
core/
lib/ Drupal/ Component/ Plugin/ Discovery/ DerivativeDiscoveryDecorator.php, line 238
Class
- DerivativeDiscoveryDecorator
- Base class providing the tools for a plugin discovery to be derivative aware.
Namespace
Drupal\Component\Plugin\DiscoveryCode
protected function mergeDerivativeDefinition($base_plugin_definition, $derivative_definition) {
// Use this definition as defaults if a plugin already defined itself as
// this derivative, but filter out empty values first.
$filtered_base = array_filter($base_plugin_definition);
$derivative_definition = $filtered_base + ($derivative_definition ?: []);
// Add back any empty keys that the derivative didn't have.
return $derivative_definition + $base_plugin_definition;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.