1.20.x entity_layout_context_handler.inc EntityLayoutContext::label()

Assemble a human-readable label of this object.

Overrides LayoutContext::label

File

modules/layout/plugins/context/entity_layout_context_handler.inc, line 25
Layout context handler for entities.

Class

EntityLayoutContext
@file Layout context handler for entities.

Code

function label() {
  $info = entity_get_info($this->entity_type);
  if (isset($this->settings['id'])) {
    if ($entity = entity_load($this->entity_type, $this->settings['id'])) {
      return t('@type: @id (@title)', array('@type' => $info['label'], '@id' => $entity->id(), '@title' => $entity->label()));
    }
    else {
      return t('Unknown @type: @id', array('@type' => $info['label'], '@id' => $this->settings['id']));
    }
  }
  if ($this->entity_type === 'user' && isset($this->name) && $this->name === 'current_user') {
    return t('Current user');
  }
  else {
    return parent::label();
  }
}