You are here

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

Gets the deriver class name from the base plugin definition.

Parameters

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

Return value

string|null The name of a class implementing \Drupal\Component\Plugin\Derivative\DeriverInterface.

Throws

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

2 calls to DerivativeDiscoveryDecorator::getDeriverClass()
ContainerDerivativeDiscoveryDecorator::getDeriver in core/lib/Drupal/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecorator.php
Gets a deriver for a base plugin.
DerivativeDiscoveryDecorator::getDeriver in core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
Gets a deriver for a base plugin.

File

core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php, line 209
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 getDeriverClass($base_definition) {
  $class = NULL;
  if ((is_array($base_definition) || ($base_definition = (array) $base_definition)) && (isset($base_definition['deriver']) && ($class = $base_definition['deriver']))) {
    if (!class_exists($class)) {
      throw new InvalidDeriverException(sprintf('Plugin (%s) deriver "%s" does not exist.', $base_definition['id'], $class));
    }
    if (!is_subclass_of($class, '\\Drupal\\Component\\Plugin\\Derivative\\DeriverInterface')) {
      throw new InvalidDeriverException(sprintf('Plugin (%s) deriver "%s" must implement \\Drupal\\Component\\Plugin\\Derivative\\DeriverInterface.', $base_definition['id'], $class));
    }
  }
  return $class;
}