You are here

function field_purge_field in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/field/field.purge.inc \field_purge_field()
  2. 7 modules/field/field.crud.inc \field_purge_field()
  3. 9 core/modules/field/field.purge.inc \field_purge_field()

Purges a field record from the database.

This function assumes all data for the field has already been purged and should only be called by field_purge_batch().

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $field: The field to purge.

Related topics

1 call to field_purge_field()
field_purge_batch in core/modules/field/field.purge.inc
Purges a batch of deleted Field API data, field storages, or fields.

File

core/modules/field/field.purge.inc, line 118
Provides support for field data purge after mass deletion.

Code

function field_purge_field(FieldDefinitionInterface $field) {

  /** @var \Drupal\Core\Field\DeletedFieldsRepositoryInterface $deleted_fields_repository */
  $deleted_fields_repository = \Drupal::service('entity_field.deleted_fields_repository');
  $deleted_fields_repository
    ->removeFieldDefinition($field);

  // Invoke external hooks after the cache is cleared for API consistency.
  \Drupal::moduleHandler()
    ->invokeAll('field_purge_field', [
    $field,
  ]);
}