You are here

function getlocations_fields_field_delete in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_fields/getlocations_fields.module \getlocations_fields_field_delete()

Implements hook_field_delete(). Define custom delete behavior for this module's field types.

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.

File

modules/getlocations_fields/getlocations_fields.module, line 360
getlocations_fields.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_fields_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if (!empty($items)) {
    $criteria = array();
    if ($entity_type == 'node') {
      $criteria = array(
        'field_name' => $field['field_name'],
        'nid' => $entity->nid,
        'vid' => $entity->vid,
      );
    }
    elseif ($entity_type == 'user' || $entity_type == 'profile2') {
      $criteria = array(
        'field_name' => $field['field_name'],
        'uid' => $entity->uid,
      );
    }
    elseif ($entity_type == 'comment') {
      $criteria = array(
        'field_name' => $field['field_name'],
        'cid' => $entity->cid,
      );
    }
    elseif ($entity_type == 'taxonomy_term') {
      $criteria = array(
        'field_name' => $field['field_name'],
        'tid' => $entity->tid,
      );
    }
    if (!empty($criteria)) {
      $items = getlocations_fields_save_locations($items, $criteria, FALSE, 'delete');
    }
  }
}