class YamlDirectoryDiscovery extends YamlDiscovery (View source)

Allows multiple YAML files per directory to define plugin definitions.

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

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(array $directories, string $file_cache_key_suffix, string $key = 'id')

Constructs a YamlDirectoryDiscovery object.

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

Set one of the YAML values as being translatable.

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(array $directories, string $file_cache_key_suffix, string $key = 'id')

Constructs a YamlDirectoryDiscovery object.

Parameters

array $directories

An array of directories to scan.

string $file_cache_key_suffix

The file cache key suffix. This should be unique for each type of discovery.

string $key

(optional) The key contained in the discovered data that identifies it. Defaults to 'id'.

$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