You are here

function _multifield_field_invoke in Multifield 7

Same name and namespace in other branches
  1. 7.2 multifield.field.inc \_multifield_field_invoke()
6 calls to _multifield_field_invoke()
multifield_field_delete in ./multifield.field.inc
Implements hook_field_delete().
multifield_field_delete_revision in ./multifield.field.inc
Implements hook_field_delete_revision().
multifield_field_insert in ./multifield.field.inc
Implements hook_field_insert().
multifield_field_presave in ./multifield.field.inc
Implements hook_field_presave().
multifield_field_update in ./multifield.field.inc
Implements hook_field_update().

... See full list

File

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

Code

function _multifield_field_invoke($op, $machine_name, $entity_type, $entity, $langcode, &$a = NULL, &$b = NULL, $options = array()) {

  // Merge default options.
  $default_options = array(
    'default' => FALSE,
    'deleted' => FALSE,
    'language' => NULL,
  );
  $options += $default_options;

  // Determine the list of instances to iterate on.
  $instances = _field_invoke_get_instances('multifield', $machine_name, $options);
  foreach ($instances as $instance) {

    // field_info_field() is not available for deleted fields, so use
    // field_info_field_by_id().
    $field = field_info_field_by_id($instance['field_id']);
    $field_name = $field['field_name'];
    $function = $options['default'] ? 'field_default_' . $op : $field['module'] . '_field_' . $op;
    if (function_exists($function)) {
      if (isset($entity->{$field_name}[$langcode])) {
        $function($entity_type, $entity, $field, $instance, $langcode, $entity->{$field_name}[$langcode], $a, $b);
      }
    }
  }
}