1. 8.2.x core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php PluginDependencyTrait
  2. 8.0.x core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php PluginDependencyTrait
  3. 8.1.x core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php PluginDependencyTrait
  4. 8.3.x core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php PluginDependencyTrait

Provides a trait for calculating the dependencies of a plugin.

Hierarchy

4 files declare their use of PluginDependencyTrait
ConfigEntityBase.php in core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
DisplayPluginBase.php in core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
Field.php in core/modules/views/src/Plugin/views/field/Field.php
VariantBase.php in core/lib/Drupal/Core/Display/VariantBase.php

File

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

Namespace

Drupal\Core\Plugin
View source
trait PluginDependencyTrait {

  use DependencyTrait;

  /**
   * 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.
   *
   * @param \Drupal\Component\Plugin\PluginInspectionInterface $instance
   *   The plugin instance.
   */
  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);
    }
  }

}

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
DependencyTrait::$dependencies protected property The object's dependencies.
DependencyTrait::addDependencies protected function Adds multiple dependencies.
DependencyTrait::addDependency protected function Adds a dependency.
PluginDependencyTrait::calculatePluginDependencies protected function Calculates and adds dependencies of a specific plugin instance.