trait PluginDependencyTrait in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php \Drupal\Core\Plugin\PluginDependencyTrait
Provides a trait for calculating the dependencies of a plugin.
Hierarchy
- trait \Drupal\Core\Plugin\PluginDependencyTrait uses DependencyTrait
3 files declare their use of PluginDependencyTrait
- ConfigEntityBase.php in core/
lib/ Drupal/ Core/ Config/ Entity/ ConfigEntityBase.php - Contains \Drupal\Core\Config\Entity\ConfigEntityBase.
- DisplayPluginBase.php in core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php - Contains \Drupal\views\Plugin\views\display\DisplayPluginBase.
- VariantBase.php in core/
lib/ Drupal/ Core/ Display/ VariantBase.php - Contains \Drupal\Core\Display\VariantBase.
File
- core/
lib/ Drupal/ Core/ Plugin/ PluginDependencyTrait.php, line 17 - Contains \Drupal\Core\Plugin\PluginDependencyTrait.
Namespace
Drupal\Core\PluginView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencyTrait:: |
protected | property | The object's dependencies. | 1 |
DependencyTrait:: |
protected | function | Adds multiple dependencies. | |
DependencyTrait:: |
protected | function | Adds a dependency. | |
PluginDependencyTrait:: |
protected | function | Calculates and adds dependencies of a specific plugin instance. | 1 |