You are here

function multifield_field_delete in Multifield 7.2

Same name and namespace in other branches
  1. 7 multifield.field.inc \multifield_field_delete()

Implements hook_field_delete().

File

./multifield.field.inc, line 424
Field integration for the Multifield module.

Code

function multifield_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
  $machine_name = multifield_extract_multifield_machine_name($field);
  foreach ($items as $delta => $item) {
    $pseudo_entity = _multifield_field_item_to_entity($machine_name, $item);

    // Run each sub-field through hook_field_delete().
    _multifield_field_invoke('delete', $machine_name, 'multifield', $pseudo_entity, $langcode);
    $items[$delta] = _multifield_field_entity_to_item($pseudo_entity);
  }

  // Invoke hook_field_delete() with the sub-field data attached to a stub of
  // the parent entity.
  $stub_entity = _multifield_create_stub_entity_with_subfield_data($machine_name, $items, array(), $entity_type, $entity, $langcode);
  _multifield_field_invoke('delete', $machine_name, $entity_type, $stub_entity, $langcode);
  if ($ids = multifield_items_extract_ids($items)) {
    entity_get_controller('multifield')
      ->resetCache($ids);
  }
}