function ConfigEntityBase::calculateDependencies

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php \Drupal\Core\Config\Entity\ConfigEntityBase::calculateDependencies()
  2. 10 core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php \Drupal\Core\Config\Entity\ConfigEntityBase::calculateDependencies()
  3. 8.9.x core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php \Drupal\Core\Config\Entity\ConfigEntityBase::calculateDependencies()
3 methods override ConfigEntityBase::calculateDependencies()
ContentLanguageSettings::calculateDependencies in core/modules/language/src/Entity/ContentLanguageSettings.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 371

Class

ConfigEntityBase
Defines a base configuration entity class.

Namespace

Drupal\Core\Config\Entity

Code

public function calculateDependencies() {
  // All dependencies should be recalculated on every save apart from enforced
  // dependencies. This ensures stale dependencies are never saved.
  $this->dependencies = array_intersect_key($this->dependencies, [
    'enforced' => '',
  ]);
  if ($this instanceof EntityWithPluginCollectionInterface) {
    // Configuration entities need to depend on the providers of any plugins
    // that they store the configuration for.
    foreach ($this->getPluginCollections() as $plugin_collection) {
      foreach ($plugin_collection as $instance) {
        $this->calculatePluginDependencies($instance);
      }
    }
  }
  if ($this instanceof ThirdPartySettingsInterface) {
    // Configuration entities need to depend on the providers of any third
    // parties that they store the configuration for.
    foreach ($this->getThirdPartyProviders() as $provider) {
      $this->addDependency('module', $provider);
    }
  }
  return $this;
}

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