protected function 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()

File

drupal/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php, line 65
Definition of 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 getDerivatives(array $base_plugin_definitions) {
  $plugin_definitions = array();
  foreach ($base_plugin_definitions as $base_plugin_id => $plugin_definition) {
    $derivative_fetcher = $this
      ->getDerivativeFetcher($base_plugin_id, $plugin_definition);
    if ($derivative_fetcher) {
      $derivative_definitions = $derivative_fetcher
        ->getDerivativeDefinitions($plugin_definition);
      foreach ($derivative_definitions as $derivative_id => $derivative_definition) {
        $plugin_id = $this
          ->encodePluginId($base_plugin_id, $derivative_id);
        $plugin_definitions[$plugin_id] = $derivative_definition;
      }
    }
    else {
      $plugin_definitions[$base_plugin_id] = $plugin_definition;
    }
  }
  return $plugin_definitions;
}