function title_entity_sync in Title 7
Synchronize replaced fields with the regular field values.
Parameters
$entity_type: The name of the entity type.
$entity: The entity to work with.
$set: Specifies the direction synchronization must be performed.
5 calls to title_entity_sync()
- TitleTranslationTestCase::testProgrammaticTranslationWorkflow in tests/
TitleTranslationTestCase.test - Tests taxonomy programmatic translation workflow.
- title_entity_load in ./
title.module - Implements hook_entity_load().
- title_entity_prepare_view in ./
title.module - Implements hook_entity_prepare_view().
- title_entity_presave in ./
title.module - Implements hook_entity_presave().
- title_field_attach_update in ./
title.module - Implements hook_field_attach_update().
2 string references to 'title_entity_sync'
- title_entity_presave in ./
title.module - Implements hook_entity_presave().
- title_entity_sync_static_reset in ./
title.module - Reset the list of entities whose fields have already been synchronized.
File
- ./
title.module, line 431
Code
function title_entity_sync($entity_type, &$entity, $langcode = NULL, $set = FALSE) {
$sync =& drupal_static(__FUNCTION__, array());
list($id, , $bundle) = entity_extract_ids($entity_type, $entity);
if (!isset($langcode)) {
$langcode = $set ? title_entity_language($entity_type, $entity) : title_active_language();
}
if (is_object($langcode)) {
$langcode = $langcode->language;
}
// We do not need to perform synchronization more than once.
if (!$set && !empty($id) && !empty($sync[$entity_type][$id][$langcode][$set])) {
return;
}
$sync[$entity_type][$id][$langcode][$set] = TRUE;
$fr_info = title_field_replacement_info($entity_type);
if ($fr_info) {
foreach ($fr_info as $legacy_field => $info) {
if (title_field_replacement_enabled($entity_type, $bundle, $legacy_field)) {
$function = 'title_field_sync_' . ($set ? 'set' : 'get');
$function($entity_type, $entity, $legacy_field, $info, $langcode);
}
}
}
}