1 field.crud.inc field_purge_field($field)

Purges a field configuration.

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

Parameters

$field: The field record to purge.

Related topics

File

core/modules/field/field.crud.inc, line 1095
Field CRUD API, handling field and field instance creation and deletion.

Code

function field_purge_field($field) {
  $instances = field_read_instances(array('field_name' => $field['field_name']), array('include_deleted' => TRUE));
  if (count($instances) > 0) {
    throw new FieldException(t('Attempt to purge a field @field_name that still has instances.', array('@field_name' => $field['field_name'])));
  }

  $config = config('field.field.' . $field['field_name']);
  $config->delete();

  // Notify the storage engine.
  module_invoke($field['storage']['module'], 'field_storage_purge_field', $field);

  // Clear the cache.
  field_info_cache_clear();

  // Invoke external hooks after the cache is cleared for API consistency.
  module_invoke_all('field_purge_field', $field);
}