You are here

public static function EntityFieldHandlerHelper::pre_render in Entity API 7

Load the entities for all rows that are about to be displayed.

Automatically takes care of relationships, including data selection relationships. Results are written into

$handler->wrappers;

and

$handler->entity_type;

is set.

9 calls to EntityFieldHandlerHelper::pre_render()
entity_views_handler_field_boolean::pre_render in views/handlers/entity_views_handler_field_boolean.inc
Load the entities for all rows that are about to be displayed.
entity_views_handler_field_date::pre_render in views/handlers/entity_views_handler_field_date.inc
Load the entities for all rows that are about to be displayed.
entity_views_handler_field_duration::pre_render in views/handlers/entity_views_handler_field_duration.inc
Load the entities for all rows that are about to be displayed.
entity_views_handler_field_entity::pre_render in views/handlers/entity_views_handler_field_entity.inc
Load the entities for all rows that are about to be displayed.
entity_views_handler_field_field::pre_render in views/handlers/entity_views_handler_field_field.inc
Load the entities for all rows that are about to be displayed.

... See full list

File

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

Class

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

Code

public static function pre_render($handler, &$values, $load_always = FALSE) {
  if (empty($values)) {
    return;
  }
  if (!$load_always && empty($handler->options['link_to_entity'])) {

    // Check whether we even need to load the entities.
    $selector = self::construct_property_selector($handler, TRUE);
    $load = FALSE;
    foreach ($values as $row) {
      if (empty($row->_entity_properties) || !array_key_exists($selector, $row->_entity_properties)) {
        $load = TRUE;
        break;
      }
    }
    if (!$load) {
      return;
    }
  }
  if (method_exists($handler->query, 'get_result_wrappers')) {
    list($handler->entity_type, $handler->wrappers) = $handler->query
      ->get_result_wrappers($values, $handler->relationship, $handler->real_field);
  }
  else {
    list($handler->entity_type, $entities) = $handler->query
      ->get_result_entities($values, $handler->relationship, $handler->real_field);
    $handler->wrappers = array();
    foreach ($entities as $id => $entity) {
      $handler->wrappers[$id] = entity_metadata_wrapper($handler->entity_type, $entity);
    }
  }
}