function hook_field_storage_delete_field

Act on deletion of a field.

This hook is invoked during the deletion of a field to ask the field storage module to mark all information stored in the field for deletion.

Parameters

$field: The field being deleted.

Related topics

2 functions implement hook_field_storage_delete_field()

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

field_sql_storage_field_storage_delete_field in drupal/core/modules/field_sql_storage/field_sql_storage.module
Implements hook_field_storage_delete_field().
field_test_field_storage_delete_field in drupal/core/modules/field/tests/modules/field_test/field_test.storage.inc
Implements hook_field_storage_delete_field().
1 invocation of hook_field_storage_delete_field()
Field::delete in drupal/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php
Implements \Drupal\Core\Entity\EntityInterface::delete().

File

drupal/core/modules/field/field.api.php, line 1618

Code

function hook_field_storage_delete_field($field) {

  // Mark all data associated with the field for deletion.
  $field['deleted'] = FALSE;
  $table = _field_sql_storage_tablename($field);
  $revision_table = _field_sql_storage_revision_tablename($field);
  db_update($table)
    ->fields(array(
    'deleted' => 1,
  ))
    ->execute();

  // Move the table to a unique name while the table contents are being deleted.
  $field['deleted'] = TRUE;
  $new_table = _field_sql_storage_tablename($field);
  $revision_new_table = _field_sql_storage_revision_tablename($field);
  db_rename_table($table, $new_table);
  db_rename_table($revision_table, $revision_new_table);
  drupal_get_schema(NULL, TRUE);
}