function ConfigEntityBase::addDependency

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php \Drupal\Core\Config\Entity\ConfigEntityBase::addDependency()
  2. 10 core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php \Drupal\Core\Config\Entity\ConfigEntityBase::addDependency()
  3. 8.9.x core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php \Drupal\Core\Config\Entity\ConfigEntityBase::addDependency()

Overrides \Drupal\Core\Entity\DependencyTrait:addDependency().

Note that this function should only be called from implementations of \Drupal\Core\Config\Entity\ConfigEntityInterface::calculateDependencies(), as dependencies are recalculated during every entity save.

See also

\Drupal\Core\Config\Entity\ConfigEntityDependency::hasDependency()

4 calls to ConfigEntityBase::addDependency()
ContentLanguageSettings::calculateDependencies in core/modules/language/src/Entity/ContentLanguageSettings.php
Calculates dependencies and stores them in the dependency property.
FieldConfig::calculateDependencies in core/modules/field/src/Entity/FieldConfig.php
Calculates dependencies and stores them in the dependency property.
FieldStorageConfig::calculateDependencies in core/modules/field/src/Entity/FieldStorageConfig.php
Calculates dependencies and stores them in the dependency property.
ResponsiveImageStyle::calculateDependencies in core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php
Calculates dependencies and stores them in the dependency property.

File

core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php, line 421

Class

ConfigEntityBase
Defines a base configuration entity class.

Namespace

Drupal\Core\Config\Entity

Code

protected function addDependency($type, $name) {
  // A config entity is always dependent on its provider. There is no need to
  // explicitly declare the dependency. An explicit dependency on Core, which
  // provides some plugins, is also not needed.
  if ($type == 'module' && ($name == $this->getEntityType()
    ->getProvider() || $name == 'core')) {
    return $this;
  }
  return $this->addDependencyTrait($type, $name);
}

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