function hook_entity_bundle_delete

Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_bundle_delete()
  2. 10 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_bundle_delete()
  3. 11.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_bundle_delete()

Act on entity_bundle_delete().

This hook is invoked after the operation has been performed.

Parameters

string $entity_type_id: The type of entity; for example, 'node' or 'user'.

string $bundle: The bundle that was just deleted.

Related topics

10 functions implement hook_entity_bundle_delete()

Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.

ContentModerationHooks::entityBundleDelete in core/modules/content_moderation/src/Hook/ContentModerationHooks.php
Implements hook_entity_bundle_delete().
content_moderation_entity_bundle_delete in core/modules/content_moderation/content_moderation.module
Implements hook_entity_bundle_delete().
EntitySchemaTestHooks::entityBundleDelete in core/modules/system/tests/modules/entity_schema_test/src/Hook/EntitySchemaTestHooks.php
Implements hook_entity_bundle_delete().
entity_schema_test_entity_bundle_delete in core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module
Implements hook_entity_bundle_delete().
FieldHooks::entityBundleDelete in core/modules/field/src/Hook/FieldHooks.php
Implements hook_entity_bundle_delete().

... See full list

2 invocations of hook_entity_bundle_delete()
EntityBundleListener::onBundleDelete in core/lib/Drupal/Core/Entity/EntityBundleListener.php
Reacts to a bundle being deleted.
EntityStorageBase::delete in core/lib/Drupal/Core/Entity/EntityStorageBase.php
Deletes permanently saved entities.

File

core/lib/Drupal/Core/Entity/entity.api.php, line 944

Code

function hook_entity_bundle_delete($entity_type_id, $bundle) {
    // Remove the settings associated with the bundle in my_module.settings.
    $config = \Drupal::config('my_module.settings');
    $bundle_settings = $config->get('bundle_settings');
    if (isset($bundle_settings[$entity_type_id][$bundle])) {
        unset($bundle_settings[$entity_type_id][$bundle]);
        $config->set('bundle_settings', $bundle_settings);
    }
}

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