function EntityBundleListener::onBundleDelete

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

Overrides EntityBundleListenerInterface::onBundleDelete

File

core/lib/Drupal/Core/Entity/EntityBundleListener.php, line 77

Class

EntityBundleListener
Reacts to entity bundle CRUD on behalf of the Entity system.

Namespace

Drupal\Core\Entity

Code

public function onBundleDelete($bundle, $entity_type_id) {
    $this->entityTypeBundleInfo
        ->clearCachedBundles();
    // Notify the entity storage.
    $storage = $this->entityTypeManager
        ->getStorage($entity_type_id);
    if ($storage instanceof EntityBundleListenerInterface) {
        $storage->onBundleDelete($bundle, $entity_type_id);
    }
    // Invoke hook_entity_bundle_delete() hook.
    $this->moduleHandler
        ->invokeAll('entity_bundle_delete', [
        $entity_type_id,
        $bundle,
    ]);
    $this->entityFieldManager
        ->clearCachedFieldDefinitions();
}

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