You are here

function diff_field_diff_view in Diff 7.3

A generic handler for parsing field values.

This callback can only handle the most basic of fields that populates the safe_value during field load or use the value column for data storage.

Parameters

array $items: An array of field items.

array $context: An associative array containing:

  • entity: The entity that the items belong to.
  • entity_type: The entity type; e.g., 'node' or 'user'.
  • bundle: The bundle name.
  • field: The field that the items belong to.
  • instance: The instance that the items belong to.
  • language: The language associated with $items.
  • old_entity: The older entity.
  • new_entity: The newer entity.

Return value

array An array of strings representing the value, keyed by delta index.

1 string reference to 'diff_field_diff_view'
diff_entity_fields_diff in ./diff.diff.inc
Internal callback to handle fieldable entities.

File

./diff.diff.inc, line 201
Includes the hooks defined by diff_hook_info().

Code

function diff_field_diff_view($items, $context) {

  // Prevent unnecessary rendering of the field. This also prevents issues
  // where field_view_field() will use a language fallback for display that
  // may not match the requested diff comparison language.
  if (!$items) {
    return array();
  }
  $diff_items = array();
  $entity = clone $context['entity'];
  $langcode = field_language($context['entity_type'], $entity, $context['field']['field_name']);
  $view_mode = empty($context['view_mode']) ? 'diff_standard' : $context['view_mode'];
  $element = field_view_field($context['entity_type'], $entity, $context['field']['field_name'], $view_mode, $langcode);
  foreach (element_children($element) as $delta) {
    $diff_items[$delta] = drupal_render($element[$delta]);
  }
  return $diff_items;
}