You are here

function entity_translation_handler_field_label::render in Entity Translation 7

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field::render

File

views/entity_translation_handler_field_label.inc, line 60
This file contains a label field handler for entity translation.

Class

entity_translation_handler_field_label
This handler shows the entity label for entities in the entity_translation table.

Code

function render($values) {
  $entity_type = $this
    ->get_value($values, 'entity_type');
  $entity_id = $this
    ->get_value($values, 'entity_id');

  // Check if entity is not empty
  if (!$entity_id || !$entity_type) {
    return NULL;
  }
  $entity = $this->entities[$entity_type][$entity_id];

  // We could also use entity_label(), but since this we might want to let
  // the handler decide what's best to show.
  $handler = entity_translation_get_handler($entity_type, $entity);
  $label = $handler
    ->getLabel();
  if ($this->options['link_to_entity']) {
    $this->options['alter']['make_link'] = TRUE;
    $this->options['alter']['path'] = $handler
      ->getViewPath();
  }
  return $label;
}