You are here

protected function TMGMTLocalTask::defaultLabel in Translation Management Tool 7

Defines the entity label if the 'entity_class_label' callback is used.

Specify 'entity_class_label' as 'label callback' in hook_entity_info() to let the entity label point to this method. Override this in order to implement a custom default label.

Overrides Entity::defaultLabel

File

translators/tmgmt_local/entity/tmgmt_local.entity.task.inc, line 95

Class

TMGMTLocalTask
Entity class for the local task entity.

Code

protected function defaultLabel() {
  if (empty($this->tuid)) {
    if (empty($this->title)) {
      return t('Task for @job', array(
        '@job' => $this
          ->getJob()
          ->label(),
      ));
    }
    else {
      return $this->title;
    }
  }
  else {
    if (empty($this->title)) {
      return t('Task for @job assigned to @translator', array(
        '@job' => $this
          ->getJob()
          ->label(),
        '@translator' => entity_label('user', user_load($this->tuid)),
      ));
    }
    else {
      return t('@title assigned to @translator', array(
        '@title' => $this->title,
        '@translator' => entity_label('user', user_load($this->tuid)),
      ));
    }
  }
}