class AnnotatedClassDiscovery extends AnnotatedClassDiscovery (View source)

Defines a discovery mechanism to find annotated plugins in PSR-4 namespaces.

Traits

Properties

protected string[] $pluginNamespaces

The namespaces within which to find plugin classes.

from  AnnotatedClassDiscovery
protected string $pluginDefinitionAnnotationName

The name of the annotation that contains the plugin definition.

from  AnnotatedClassDiscovery
protected Reader $annotationReader

The doctrine annotation reader.

from  AnnotatedClassDiscovery
protected string[] $annotationNamespaces

Additional namespaces to be scanned for annotation classes.

from  AnnotatedClassDiscovery
protected FileCacheInterface $fileCache

The file cache object.

from  AnnotatedClassDiscovery
protected string $directorySuffix

A suffix to append to each PSR-4 directory associated with a base namespace, to form the directories where plugins are found.

protected string $namespaceSuffix

A suffix to append to each base namespace, to obtain the namespaces where plugins are found.

protected Traversable $rootNamespacesIterator

A list of base namespaces with their PSR-4 directories.

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(string $subdir, Traversable $root_namespaces, string $plugin_definition_annotation_name = 'Drupal\\Component\\Annotation\\Plugin', array $annotation_namespaces = [])

Constructs an AnnotatedClassDiscovery object.

Reader
getAnnotationReader()

Gets the used doctrine annotation reader.

prepareAnnotationDefinition(AnnotationInterface $annotation, string $class)

Prepares the annotation definition.

string[]
getPluginNamespaces()

Gets an array of PSR-4 namespaces to search for plugin classes.

string|null
getProviderFromNamespace(string $namespace)

Extracts the provider name from a Drupal namespace.

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(string $subdir, Traversable $root_namespaces, string $plugin_definition_annotation_name = 'Drupal\\Component\\Annotation\\Plugin', array $annotation_namespaces = [])

Constructs an AnnotatedClassDiscovery object.

Parameters

string $subdir

Either the plugin's subdirectory, for example 'Plugin/views/filter', or empty string if plugins are located at the top level of the namespace.

Traversable $root_namespaces

An object that implements \Traversable which contains the root paths keyed by the corresponding namespace to look for plugin implementations. If $subdir is not an empty string, it will be appended to each namespace.

string $plugin_definition_annotation_name

(optional) The name of the annotation that contains the plugin definition. Defaults to 'Drupal\Component\Annotation\Plugin'.

array $annotation_namespaces

(optional) Additional namespaces to be scanned for annotation classes.

protected Reader getAnnotationReader()

Gets the used doctrine annotation reader.

Return Value

Reader

The annotation reader.

protected prepareAnnotationDefinition(AnnotationInterface $annotation, string $class)

Prepares the annotation definition.

Parameters

AnnotationInterface $annotation

The annotation derived from the plugin.

string $class

The class used for the plugin.

protected string[] getPluginNamespaces()

Gets an array of PSR-4 namespaces to search for plugin classes.

Return Value

string[]

protected string|null getProviderFromNamespace(string $namespace)

Extracts the provider name from a Drupal namespace.

Parameters

string $namespace

The namespace to extract the provider from.

Return Value

string|null

The matching provider name, or NULL otherwise.