function hook_entity_bundle_delete

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_bundle_delete()
  2. 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_bundle_delete()
  3. 10 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

1 function implements 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.

entity_schema_test_entity_bundle_delete in core/modules/system/tests/modules/entity_schema_test/entity_schema_test.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 940

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.