You are here

function entity_metadata_field_verbatim_get in Entity API 7

Callback to verbatim get the data structure of a field. Useful for fields that add metadata for their own data structure.

4 string references to 'entity_metadata_field_verbatim_get'
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 523
Provides various callbacks for the whole core module integration.

Code

function entity_metadata_field_verbatim_get($entity, array $options, $name, $entity_type, &$context) {

  // Set contextual info useful for getters of any child properties.
  $context['instance'] = field_info_instance($context['parent']
    ->type(), $name, $context['parent']
    ->getBundle());
  $context['field'] = field_info_field($name);
  $langcode = isset($options['language']) ? $options['language']->language : LANGUAGE_NONE;
  $langcode = entity_metadata_field_get_language($entity_type, $entity, $context['field'], $langcode, TRUE);
  if ($context['field']['cardinality'] == 1) {
    return isset($entity->{$name}[$langcode][0]) ? $entity->{$name}[$langcode][0] : NULL;
  }
  return isset($entity->{$name}[$langcode]) ? $entity->{$name}[$langcode] : array();
}