You are here

function title_entity_load in Title 7

Implements hook_entity_load().

Since the result of field_attach_load() is cached, synchronization must be performed also here to ensure that there is always the correct value in the replaced fields.

2 calls to title_entity_load()
title_entitycache_load in ./title.module
Implements hook_entitycache_load().
title_field_attach_load in ./title.module
Implements hook_field_attach_load().

File

./title.module, line 218

Code

function title_entity_load($entities, $type) {

  // Load entity translations otherwise field language will not be computed
  // correctly.
  if (module_exists('entity_translation')) {
    module_invoke('entity_translation', 'entity_load', $entities, $type);
  }
  foreach ($entities as &$entity) {

    // Synchronize values from the regular field unless we are intializing it.
    // When the node is not being edited, the language must be set to current
    // entity language if set, otherwise NULL.
    $language = NULL;
    if (preg_match('/node\\/\\d+\\/edit/', current_path()) == 0 && preg_match('/node\\/\\d+$/', current_path()) == 0) {
      if (!empty($entity->language)) {
        $language = $entity->language;
      }
    }
    title_entity_sync($type, $entity, $language, !empty($GLOBALS['title_field_replacement_init']));
  }
}