You are here

public static function EntityFieldHandlerHelper::render_entity_link in Entity API 7

Render a single value as a link to the entity if applicable.

Parameters

$handler: The field handler whose field is rendered.

$value: The single value to render.

$values: The values for the current row retrieved from the Views query, as an object.

Return value

string The rendered value.

2 calls to EntityFieldHandlerHelper::render_entity_link()
EntityFieldHandlerHelper::render in views/handlers/entity_views_field_handler_helper.inc
Render the field.
EntityFieldHandlerHelper::render_list in views/handlers/entity_views_field_handler_helper.inc
Render a list of values.

File

views/handlers/entity_views_field_handler_helper.inc, line 485
Contains the EntityFieldHandlerHelper class.

Class

EntityFieldHandlerHelper
Helper class containing static implementations of common field handler methods.

Code

public static function render_entity_link($handler, $value, $values) {

  // Allow easy overriding of this behaviour in the specific field handler.
  if (method_exists($handler, 'render_entity_link')) {
    return $handler
      ->render_entity_link($value, $values);
  }
  $render = self::render_single_value($handler, $value, $values);
  if (!$handler->options['link_to_entity']) {
    return $render;
  }
  $entity = $handler
    ->get_value($values, 'entity object');
  if (is_object($entity) && ($url = entity_uri($handler->entity_type, $entity))) {
    return l($render, $url['path'], array(
      'html' => TRUE,
    ) + $url['options']);
  }
  return $render;
}