function DependencyTrait::addDependencies

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/DependencyTrait.php \Drupal\Core\Entity\DependencyTrait::addDependencies()
  2. 8.9.x core/lib/Drupal/Core/Entity/DependencyTrait.php \Drupal\Core\Entity\DependencyTrait::addDependencies()
  3. 10 core/lib/Drupal/Core/Entity/DependencyTrait.php \Drupal\Core\Entity\DependencyTrait::addDependencies()

Adds multiple dependencies.

Parameters

array $dependencies: An array of dependencies keyed by the type of dependency. One example:

[
    'module' => [
        'node',
        'field',
        'image',
    ],
];

See also

\Drupal\Core\Entity\DependencyTrait::addDependency

4 calls to DependencyTrait::addDependencies()
FieldConfigBase::calculateDependencies in core/lib/Drupal/Core/Field/FieldConfigBase.php
Calculates dependencies and stores them in the dependency property.
FieldStorageConfig::calculateDependencies in core/modules/field/src/Entity/FieldStorageConfig.php
PluginDependencyTrait::calculatePluginDependencies in core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php
Calculates and adds dependencies of a specific plugin instance.
Role::calculateDependencies in core/modules/user/src/Entity/Role.php

File

core/lib/Drupal/Core/Entity/DependencyTrait.php, line 64

Class

DependencyTrait
Provides a trait for managing an object's dependencies.

Namespace

Drupal\Core\Entity

Code

protected function addDependencies(array $dependencies) {
    foreach ($dependencies as $dependency_type => $list) {
        foreach ($list as $name) {
            $this->addDependency($dependency_type, $name);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.