function entity_schema_test_entity_bundle_delete

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module \entity_schema_test_entity_bundle_delete()
  2. 8.9.x core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module \entity_schema_test_entity_bundle_delete()
  3. 10 core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module \entity_schema_test_entity_bundle_delete()

Implements hook_entity_bundle_delete().

File

core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module, line 95

Code

function entity_schema_test_entity_bundle_delete($entity_type_id, $bundle) {
    if ($entity_type_id == 'entity_test_update' && $bundle == 'custom') {
        $field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions($entity_type_id, $bundle);
        // Notify the entity storage that our field is gone.
        \Drupal::service('field_definition.listener')->onFieldDefinitionDelete($field_definitions['custom_bundle_field']);
        \Drupal::service('field_storage_definition.listener')->onFieldStorageDefinitionDelete($field_definitions['custom_bundle_field']->getFieldStorageDefinition());
    }
}

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