You are here

protected function DerivativeDiscoveryDecorator::mergeDerivativeDefinition in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 233
Contains \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator.

Class

DerivativeDiscoveryDecorator
Base class providing the tools for a plugin discovery to be derivative aware.

Namespace

Drupal\Component\Plugin\Discovery

Code

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 ?: array());

  // Add back any empty keys that the derivative didn't have.
  return $derivative_definition + $base_plugin_definition;
}