function title_entity_label in Title 7
Implements callback_entity_info_label().
1 string reference to 'title_entity_label'
- title_entity_info_alter in ./
title.module - Implements hook_entity_info_alter().
File
- ./
title.module, line 118
Code
function title_entity_label($entity, $type, $langcode = NULL) {
$entity_info = entity_get_info($type);
$legacy_field = $entity_info['entity keys']['label'];
$info = $entity_info['field replacement'][$legacy_field];
list(, , $bundle) = entity_extract_ids($type, $entity);
// If field replacement is enabled we use the replacing field value.
if (title_field_replacement_enabled($type, $bundle, $legacy_field)) {
$langcode = field_language($type, $entity, $info['field']['field_name'], $langcode);
$values = $info['callbacks']['sync_get']($type, $entity, $legacy_field, $info, $langcode);
return isset($values[$legacy_field]) ? $values[$legacy_field] : $entity->{$legacy_field};
}
if (isset($entity_info['label fallback']['title']) && function_exists($entity_info['label fallback']['title'])) {
$label = $entity_info['label fallback']['title']($entity, $type, $langcode);
return isset($label) ? $label : $entity->{$legacy_field};
}
// Otherwise if we have a fallback defined we use the original label callback.
return property_exists($entity, $legacy_field) ? $entity->{$legacy_field} : NULL;
}