trait PluginDependencyTrait (View source)

Provides a trait for calculating the dependencies of a plugin.

Traits

Provides a trait for managing an object's dependencies.

Properties

protected array $dependencies

The object's dependencies.

from  DependencyTrait

Methods

$this
addDependency(string $type, string $name)

Adds a dependency.

addDependencies(array $dependencies)

Adds multiple dependencies.

array
getPluginDependencies(PluginInspectionInterface $instance)

Calculates and returns dependencies of a specific plugin instance.

calculatePluginDependencies(PluginInspectionInterface $instance)

Calculates and adds dependencies of a specific plugin instance.

moduleHandler()

Wraps the module handler.

themeHandler()

Wraps the theme handler.

Details

protected $this addDependency(string $type, string $name)

Adds a dependency.

Parameters

string $type

Type of dependency being added: 'module', 'theme', 'config', 'content'.

string $name

If $type is 'module' or 'theme', the name of the module or theme. If $type is 'config' or 'content', the result of EntityInterface::getConfigDependencyName().

Return Value

$this

See also

EntityInterface::getConfigDependencyName

protected addDependencies(array $dependencies)

Adds multiple dependencies.

Parameters

array $dependencies

An array of dependencies keyed by the type of dependency. One example: @code array( 'module' => array( 'node', 'field', 'image', ), ); @endcode

See also

DependencyTrait::addDependency

protected array getPluginDependencies(PluginInspectionInterface $instance)

Calculates and returns dependencies of a specific plugin instance.

Dependencies are added for the module that provides the plugin, as well as any dependencies declared by the instance's calculateDependencies() method, if it implements \Drupal\Component\Plugin\DependentPluginInterface.

Parameters

PluginInspectionInterface $instance

The plugin instance.

Return Value

array

An array of dependencies keyed by the type of dependency.

protected calculatePluginDependencies(PluginInspectionInterface $instance)

Calculates and adds dependencies of a specific plugin instance.

Dependencies are added for the module that provides the plugin, as well as any dependencies declared by the instance's calculateDependencies() method, if it implements \Drupal\Component\Plugin\DependentPluginInterface.

Parameters

PluginInspectionInterface $instance

The plugin instance.

protected ModuleHandlerInterface moduleHandler()

Wraps the module handler.

Return Value

ModuleHandlerInterface

The module handler.

protected ThemeHandlerInterface themeHandler()

Wraps the theme handler.

Return Value

ThemeHandlerInterface

The theme handler.