function title_field_sync_get in Title 7
Synchronize a single legacy field with its regular field value.
Parameters
$entity_type: The name of the entity type.
$entity: The entity to work with.
$legacy_field: The name of the legacy field to be replaced.
$info: Field replacement information for the given entity.
$langcode: The field language to use for the source value.
1 call to title_field_sync_get()
- title_field_attach_submit in ./
title.module - Implements hook_field_attach_submit().
File
- ./
title.module, line 495
Code
function title_field_sync_get($entity_type, $entity, $legacy_field, $info, $langcode = NULL) {
if (property_exists($entity, $legacy_field)) {
// Save the legacy field value to LEGACY_FIELD_NAME_original.
$entity->{$legacy_field . '_original'} = $entity->{$legacy_field};
// Find out the actual language to use (field might be untranslatable).
$langcode = field_language($entity_type, $entity, $info['field']['field_name'], $langcode);
$values = $info['callbacks']['sync_get']($entity_type, $entity, $legacy_field, $info, $langcode);
foreach ($values as $name => $value) {
if ($value !== NULL) {
$entity->{$name} = $value;
}
}
// Save the actual language used to LEGACY_FIELD_NAME_language.
$entity->{$legacy_field . '_language'} = $langcode;
// Ensure we do not pollute field language static cache.
$cache =& drupal_static('field_language');
list($id, , ) = entity_extract_ids($entity_type, $entity);
unset($cache[$entity_type][$id]);
}
}