You are here

party_hat.entity_merge.inc in Party 7

Integration with the merge module.

File

modules/party_hat/party_hat.entity_merge.inc
View source
<?php

/**
 * @file
 * Integration with the merge module.
 */

/**
 * Implements hook_entity_merge_field_items_alter().
 */
function party_hat_entity_merge_field_items_alter(&$items, $target_entity, $context) {
  if ($context['field']['type'] != 'hat_reference') {
    return;
  }
  $has_hats = array();
  foreach ($items as $delta => $item) {
    if (in_array($item['hat_name'], $has_hats) || empty($item['hat_name'])) {
      unset($items[$delta]);
    }
    else {
      $has_hats[] = $item['hat_name'];
    }
  }
}

Functions

Namesort descending Description
party_hat_entity_merge_field_items_alter Implements hook_entity_merge_field_items_alter().