protected function DerivativeDiscoveryDecorator::getDerivativeFetcher

Finds a Drupal\Component\Plugin\Discovery\DerivativeInterface.

This Drupal\Component\Plugin\Discovery\DerivativeInterface can fetch derivatives for the plugin.

Parameters

string $base_plugin_id: The base plugin id of the plugin.

array $base_definition: The base plugin definition to build derivatives.

Return value

Drupal\Component\Plugin\Discovery\DerivativeInterface|null A DerivativeInterface or null if none exists for the plugin.

2 calls to DerivativeDiscoveryDecorator::getDerivativeFetcher()
DerivativeDiscoveryDecorator::getDefinition in drupal/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
Implements Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinition().
DerivativeDiscoveryDecorator::getDerivatives in drupal/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
Adds derivatives to a list of plugin definitions.

File

drupal/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php, line 140
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 getDerivativeFetcher($base_plugin_id, array $base_definition) {
  if (!isset($this->derivativeFetchers[$base_plugin_id])) {
    $this->derivativeFetchers[$base_plugin_id] = FALSE;
    if (isset($base_definition['derivative'])) {
      $class = $base_definition['derivative'];
      $this->derivativeFetchers[$base_plugin_id] = new $class($base_plugin_id);
    }
  }
  return $this->derivativeFetchers[$base_plugin_id] ?: NULL;
}