function hook_entity_bundle_delete

Same name 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

5 functions implement hook_entity_bundle_delete()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

content_moderation_entity_bundle_delete in core/modules/content_moderation/content_moderation.module
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().
field_entity_bundle_delete in core/modules/field/field.module
Implements hook_entity_bundle_delete().
jsonapi_entity_bundle_delete in core/modules/jsonapi/jsonapi.module
Implements hook_entity_bundle_delete().
language_entity_bundle_delete in core/modules/language/language.module
Implements hook_entity_bundle_delete().
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.