class ContainerDerivativeDiscoveryDecorator extends DerivativeDiscoveryDecorator (View source)

Injects dependencies into derivers if they use ContainerDeriverInterface.

Traits

Properties

protected DeriverInterface[] $derivers

Plugin derivers.

from  DerivativeDiscoveryDecorator
protected DiscoveryInterface $decorated

The decorated plugin discovery.

from  DerivativeDiscoveryDecorator

Methods

getDefinitions()

{@inheritdoc}

getDefinition($plugin_id, $exception_on_invalid = TRUE)

{@inheritdoc}

array|null
doGetDefinition(array $definitions, string $plugin_id, bool $exception_on_invalid)

Gets a specific plugin definition.

hasDefinition($plugin_id)

{@inheritdoc}

__construct(DiscoveryInterface $decorated)

Creates a new instance.

getDerivatives(array $base_plugin_definitions)

Adds derivatives to a list of plugin definitions.

array
decodePluginId(string $plugin_id)

Decodes derivative id and plugin id from a string.

string
encodePluginId(string $base_plugin_id, string $derivative_id)

Encodes plugin and derivative id's into a string.

getDeriver(string $base_plugin_id, mixed $base_definition)

Gets a deriver for a base plugin.

string|null
getDeriverClass(array $base_definition)

Gets the deriver class name from the base plugin definition.

array
mergeDerivativeDefinition(array $base_plugin_definition, array $derivative_definition)

Merges a base and derivative definition, taking into account empty values.

__call($method, $args)

Passes through all unknown calls onto the decorated object.

Details

abstract getDefinitions()

{@inheritdoc}

getDefinition($plugin_id, $exception_on_invalid = TRUE)

{@inheritdoc}

Parameters

$plugin_id
$exception_on_invalid

protected array|null doGetDefinition(array $definitions, string $plugin_id, bool $exception_on_invalid)

Gets a specific plugin definition.

Parameters

array $definitions

An array of the available plugin definitions.

string $plugin_id

A plugin id.

bool $exception_on_invalid

If TRUE, an invalid plugin ID will cause an exception to be thrown; if FALSE, NULL will be returned.

Return Value

array|null

A plugin definition, or NULL if the plugin ID is invalid and $exception_on_invalid is TRUE.

Exceptions

PluginNotFoundException

hasDefinition($plugin_id)

{@inheritdoc}

Parameters

$plugin_id

__construct(DiscoveryInterface $decorated)

Creates a new instance.

Parameters

DiscoveryInterface $decorated

The parent object implementing DiscoveryInterface that is being decorated.

protected getDerivatives(array $base_plugin_definitions)

Adds derivatives to a list of plugin definitions.

This should be called by the class extending this in DiscoveryInterface::getDefinitions().

Parameters

array $base_plugin_definitions

protected array decodePluginId(string $plugin_id)

Decodes derivative id and plugin id from a string.

Parameters

string $plugin_id

Plugin identifier that may point to a derivative plugin.

Return Value

array

An array with the base plugin id as the first index and the derivative id as the second. If there is no derivative id it will be null.

protected string encodePluginId(string $base_plugin_id, string $derivative_id)

Encodes plugin and derivative id's into a string.

Parameters

string $base_plugin_id

The base plugin identifier.

string $derivative_id

The derivative identifier.

Return Value

string

A uniquely encoded combination of the $base_plugin_id and $derivative_id.

protected DeriverInterface|null getDeriver(string $base_plugin_id, mixed $base_definition)

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

DeriverInterface|null

A DerivativeInterface or NULL if none exists for the plugin.

Exceptions

InvalidDeriverException

protected string|null getDeriverClass(array $base_definition)

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.

Exceptions

InvalidDeriverException

protected array mergeDerivativeDefinition(array $base_plugin_definition, array $derivative_definition)

Merges a base and derivative definition, taking into account empty values.

Parameters

array $base_plugin_definition

The base plugin definition.

array $derivative_definition

The derivative plugin definition.

Return Value

array

The merged definition.

__call($method, $args)

Passes through all unknown calls onto the decorated object.

Parameters

$method
$args