You are here

function title_field_text_sync_get in Title 7

Sync callback for the text field type.

File

./title.core.inc, line 133
Provide field replacement information.

Code

function title_field_text_sync_get($entity_type, $entity, $legacy_field, $info, $langcode) {
  $value = NULL;
  $format = 'plain_text';
  $info += array(
    'additional keys' => array(
      'format' => 'format',
    ),
  );
  $format_key = $info['additional keys']['format'];
  $field_name = $info['field']['field_name'];

  // Return values only if there is any available to process for the current
  // language.
  if (!empty($entity->{$field_name}[$langcode]) && is_array($entity->{$field_name}[$langcode])) {
    $item = $entity->{$field_name}[$langcode][0] + array(
      'value' => NULL,
      'format' => NULL,
    );
    $value = $item['value'];
    $format = $item['format'];
  }
  return array(
    $legacy_field => $value,
    $format_key => $format,
  );
}