You are here

protected function DerivativeDiscoveryDecorator::mergeDerivativeDefinition in Service Container 7

Same name and namespace in other branches
  1. 7.2 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 lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
DerivativeDiscoveryDecorator::getDerivatives in lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
Adds derivatives to a list of plugin definitions.

File

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;
}