function ConfigEntityBase::onDependencyRemoval

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php \Drupal\Core\Config\Entity\ConfigEntityBase::onDependencyRemoval()
  2. 10 core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php \Drupal\Core\Config\Entity\ConfigEntityBase::onDependencyRemoval()
  3. 9 core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php \Drupal\Core\Config\Entity\ConfigEntityBase::onDependencyRemoval()
  4. 8.9.x core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php \Drupal\Core\Config\Entity\ConfigEntityBase::onDependencyRemoval()
3 methods override ConfigEntityBase::onDependencyRemoval()
ConfigTest::onDependencyRemoval in core/modules/config/tests/config_test/src/Entity/ConfigTest.php
Informs the entity that entities it depends on will be deleted.
FilterFormat::onDependencyRemoval in core/modules/filter/src/Entity/FilterFormat.php
Informs the entity that entities it depends on will be deleted.
View::onDependencyRemoval in core/modules/views/src/Entity/View.php
Informs the entity that entities it depends on will be deleted.

File

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

Class

ConfigEntityBase
Defines a base configuration entity class.

Namespace

Drupal\Core\Config\Entity

Code

public function onDependencyRemoval(array $dependencies) {
  $changed = FALSE;
  if (!empty($this->third_party_settings)) {
    $old_count = count($this->third_party_settings);
    $this->third_party_settings = array_diff_key($this->third_party_settings, array_flip($dependencies['module']));
    $changed = $old_count != count($this->third_party_settings);
  }
  if ($this instanceof EntityWithPluginCollectionInterface) {
    // Allow associated plugins to recalculate their dependencies and update
    // settings on dependency removal.
    foreach ($this->getPluginCollections() as $plugin_collection) {
      foreach ($plugin_collection as $id => $instance) {
        if ($instance instanceof RemovableDependentPluginInterface) {
          $changed = match ($instance->onCollectionDependencyRemoval($dependencies)) {  RemovableDependentPluginReturn::Remove => $plugin_collection->removeInstanceId($id) || TRUE,
            RemovableDependentPluginReturn::Changed => TRUE,
            RemovableDependentPluginReturn::Unchanged => $changed,
          
          };
        }
      }
    }
  }
  return $changed;
}

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