You are here

function _computed_field_compute_value in Computed Field 7

Same name and namespace in other branches
  1. 5 computed_field.module \_computed_field_compute_value()
  2. 6 computed_field.module \_computed_field_compute_value()

Private function to compute the fields value.

4 calls to _computed_field_compute_value()
computed_field_field_insert in ./computed_field.module
Implements hook_field_insert().
computed_field_field_load in ./computed_field.module
Implements hook_field_load().
computed_field_field_prepare_view in ./computed_field.module
Implements hook_field_prepare_view().
computed_field_field_update in ./computed_field.module
Implements hook_field_update().

File

./computed_field.module, line 499
Functionality for the computed field.

Code

function _computed_field_compute_value($entity_type, $entity, $field, $instance, $langcode, &$items) {
  $settings = $field['settings'];

  // Setup a variable with the field values.
  $entity_field =& $items;

  // Setup a variable with the entity language if available.
  if (isset($entity->language)) {
    $entity_lang = $entity->language;
  }
  else {
    $entity_lang = LANGUAGE_NONE;
  }

  // Allow the value to be computed from code not stored in DB.
  $compute_func = 'computed_field_' . $field['field_name'] . '_compute';
  if (function_exists($compute_func)) {
    $compute_func($entity_field, $entity_type, $entity, $field, $instance, $langcode, $items);
  }
  elseif (isset($settings['code'])) {
    eval($settings['code']);
  }
}