public function LingotekEntity::getTitle in Lingotek Translation 7.7
Same name and namespace in other branches
- 7.5 lib/Drupal/lingotek/LingotekEntity.php \LingotekEntity::getTitle()
- 7.6 lib/Drupal/lingotek/LingotekEntity.php \LingotekEntity::getTitle()
Overrides LingotekTranslatableEntity::getTitle
3 calls to LingotekEntity::getTitle()
- LingotekEntity::getDescription in lib/
Drupal/ lingotek/ LingotekEntity.php - LingotekEntity::getDocumentName in lib/
Drupal/ lingotek/ LingotekEntity.php - LingotekEntity::getNote in lib/
Drupal/ lingotek/ LingotekEntity.php
File
- lib/
Drupal/ lingotek/ LingotekEntity.php, line 285 - Defines LingotekEntity.
Class
- LingotekEntity
- A class wrapper for Lingotek-specific behavior on nodes.
Code
public function getTitle() {
if (!empty($this->title)) {
return $this->title;
}
try {
$title_field = field_get_items($this->entity_type, $this->entity, 'title_field', $this->language);
$this->title = $title_field[0]['value'];
if (!empty($this->title)) {
return $this->title;
}
} catch (Exception $e) {
// Must not have values in the title field, so continue.
}
if (!empty($this->info['entity keys']['label']) && !empty($this->entity->{$this->info['entity keys']['label']})) {
$this->title = $this->entity->{$this->info['entity keys']['label']};
}
elseif ($this->entity_type == 'comment') {
$this->title = $this->entity->subject;
}
else {
LingotekLog::info('Did not find a label for @entity_type #!entity_id, using default label.', array(
'@entity_type' => $this->entity_type,
'@entity_id' => $this->entity_id,
));
$this->title = $this->entity_type . " #" . $this->entity_id;
if ($this->entity_type === 'paragraphs_item') {
list($parent_id, $parent_title) = lingotek_get_paragraph_parent_info($this->entity_type, $this->entity_id);
$this->title .= ' (Host entity: ' . $parent_title . ')';
}
}
return $this->title;
}