hook_field_delete

function hook_field_delete

hook_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items)

Define custom delete behavior for this module's field data.

This hook is invoked from field_attach_delete() on the module that defines a field, during the process of deleting an entity object (node, taxonomy term, etc.). It is invoked just before the data for this field on the particular entity object is deleted from field storage. Only field modules that are storing or tracking information outside the standard field storage mechanism need to implement this hook.

Parameters

$entity_type: The type of $entity.

$entity: The entity for the operation.

$field: The field structure for the operation.

$instance: The instance structure for $field on $entity's bundle.

$langcode: The language associated with $items.

$items: $entity->{$field['field_name']}[$langcode], or an empty array if unset.

See also

hook_field_insert()

hook_field_update()

Related topics

File

modules/field/field.api.php, line 604
Hooks provided by the Field module.

Code

function hook_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
  foreach ($items as $delta => $item) {
    // For hook_file_references(), remember that this is being deleted.
    $item['file_field_name'] = $field['field_name'];
    // Pass in the ID of the object that is being removed so all references can
    // be counted in hook_file_references().
    $item['file_field_type'] = $entity_type;
    $item['file_field_id'] = $id;
    file_field_delete_file($item, $field, $entity_type, $id);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!field!field.api.php/function/hook_field_delete/7.x

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部