You are here

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

1 call to DerivativeDiscoveryDecorator::getDeriverClass()
DerivativeDiscoveryDecorator::getDeriver in lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
Gets a deriver for a base plugin.

File

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