You are here

function entity_metadata_field_verbatim_set in Entity API 7

Writes the passed field items in the object. Useful as field level setter to set the whole data structure at once.

4 string references to 'entity_metadata_field_verbatim_set'
entity_metadata_comment_entity_property_info_alter in modules/comment.info.inc
Implements hook_entity_property_info_alter() on top of comment module.
entity_metadata_field_file_callback in modules/field.info.inc
Additional callback to adapt the property info for file fields.
entity_metadata_field_text_property_callback in modules/field.info.inc
Additional callback to adapt the property info for text fields. If a text field is processed we make use of a separate data structure so that format filters are available too. For the text value that is sanitized, this processed value is returned by…
entity_metadata_node_entity_property_info_alter in modules/node.info.inc
Implements hook_entity_property_info_alter() on top of node module.

File

modules/callbacks.inc, line 540
Provides various callbacks for the whole core module integration.

Code

function entity_metadata_field_verbatim_set($entity, $name, $items, $langcode, $entity_type) {
  $field = field_info_field($name);
  $langcode = entity_metadata_field_get_language($entity_type, $entity, $field, $langcode);
  $value = $field['cardinality'] == 1 ? array(
    $items,
  ) : (array) $items;

  // Filter out any items set to NULL.
  $entity->{$name}[$langcode] = array_filter($value);

  // Empty the static field language cache, so the field system picks up any
  // possible new languages.
  drupal_static_reset('field_language');
}