class YamlDiscoveryDecorator extends YamlDiscovery (View source)

Enables YAML discovery for plugin definitions.

You should normally extend this class to add validation for the values in the YAML data or to restrict use of the class or derivatives keys.

Traits

Properties

protected YamlDiscovery $discovery

YAML file discovery and parsing handler.

from  YamlDiscovery
protected array $translatableProperties

Contains an array of translatable properties passed along to t().

from  YamlDiscovery
protected DiscoveryInterface $decorated

The Discovery object being decorated.

Methods

array
getDefinitions()

Gets the definition of all plugins for this type.

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, string $name, array $directories)

Constructs a YamlDiscoveryDecorator object.

$this
addTranslatableProperty(string $value_key, string $context_key = '')

Set one of the YAML values as being translatable.

__call($method, $args)

Passes through all unknown calls onto the decorated object.

Details

array getDefinitions()

Gets the definition of all plugins for this type.

Return Value

array

An array of plugin definitions (empty array if no definitions were found). Keys are plugin IDs.

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, string $name, array $directories)

Constructs a YamlDiscoveryDecorator object.

Parameters

DiscoveryInterface $decorated

The discovery object that is being decorated.

string $name

The file name suffix to use for discovery; for example, 'test' will become 'MODULE.test.yml'.

array $directories

An array of directories to scan.

$this addTranslatableProperty(string $value_key, string $context_key = '')

Set one of the YAML values as being translatable.

Parameters

string $value_key

The key corresponding to the value in the YAML that contains a translatable string.

string $context_key

(Optional) the translation context for the value specified by the $value_key.

Return Value

$this

__call($method, $args)

Passes through all unknown calls onto the decorated object.

Parameters

$method
$args