8.3.x PluginDependencyTrait.php protected PluginDependencyTrait::calculatePluginDependencies(PluginInspectionInterface $instance)
8.0.x PluginDependencyTrait.php protected PluginDependencyTrait::calculatePluginDependencies(PluginInspectionInterface $instance)
8.1.x PluginDependencyTrait.php protected PluginDependencyTrait::calculatePluginDependencies(PluginInspectionInterface $instance)
8.2.x PluginDependencyTrait.php protected PluginDependencyTrait::calculatePluginDependencies(PluginInspectionInterface $instance)
8.4.x PluginDependencyTrait.php protected PluginDependencyTrait::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

\Drupal\Component\Plugin\PluginInspectionInterface $instance: The plugin instance.

4 calls to PluginDependencyTrait::calculatePluginDependencies()
ConfigEntityBase::calculateDependencies in core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
Calculates dependencies and stores them in the dependency property.
Field::calculateDependencies in core/modules/views/src/Plugin/views/field/Field.php
Calculates dependencies for the configured plugin.
FilterFormat::calculatePluginDependencies in core/modules/filter/src/Entity/FilterFormat.php
Calculates and adds dependencies of a specific plugin instance.
View::calculateDependencies in core/modules/views/src/Entity/View.php
Calculates dependencies and stores them in the dependency property.
1 method overrides PluginDependencyTrait::calculatePluginDependencies()
FilterFormat::calculatePluginDependencies in core/modules/filter/src/Entity/FilterFormat.php
Calculates and adds dependencies of a specific plugin instance.

File

core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php, line 27

Class

PluginDependencyTrait
Provides a trait for calculating the dependencies of a plugin.

Namespace

Drupal\Core\Plugin

Code

protected function calculatePluginDependencies(PluginInspectionInterface $instance) {
  $definition = $instance->getPluginDefinition();
  $this->addDependency('module', $definition['provider']);
  // Plugins can declare additional dependencies in their definition.
  if (isset($definition['config_dependencies'])) {
    $this->addDependencies($definition['config_dependencies']);
  }
  // If a plugin is dependent, calculate its dependencies.
  if ($instance instanceof DependentPluginInterface && $plugin_dependencies = $instance->calculateDependencies()) {
    $this->addDependencies($plugin_dependencies);
  }
}