You are here

protected function DerivativeDiscoveryDecorator::getDeriver in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator::getDeriver()
  2. 10 core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator::getDeriver()

Gets a deriver for a base plugin.

Parameters

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

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

Return value

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

Throws

\Drupal\Component\Plugin\Exception\InvalidDeriverException Thrown if the 'deriver' class specified in the plugin definition does not implement \Drupal\Component\Plugin\Derivative\DeriverInterface.

2 calls to DerivativeDiscoveryDecorator::getDeriver()
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.
1 method overrides DerivativeDiscoveryDecorator::getDeriver()
ContainerDerivativeDiscoveryDecorator::getDeriver in core/lib/Drupal/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecorator.php
Gets a deriver for a base plugin.

File

core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php, line 179

Class

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

Namespace

Drupal\Component\Plugin\Discovery

Code

protected function getDeriver($base_plugin_id, $base_definition) {
  if (!isset($this->derivers[$base_plugin_id])) {
    $this->derivers[$base_plugin_id] = FALSE;
    $class = $this
      ->getDeriverClass($base_definition);
    if ($class) {
      $this->derivers[$base_plugin_id] = new $class($base_plugin_id);
    }
  }
  return $this->derivers[$base_plugin_id] ?: NULL;
}