You are here

function party_plugin_row_attached_entity::pre_render in Party 7

Same name and namespace in other branches
  1. 8.2 includes/views/party_plugin_row_attached_entity.inc \party_plugin_row_attached_entity::pre_render()

Use entity_load() to load all entities at once if they aren't loaded yet.

Overrides views_plugin_row::pre_render

File

includes/views/party_plugin_row_attached_entity.inc, line 40
Row style plugin for displaying entities attached to a party. This will produce multiple rows per party, and is mostly intended for views which are filtered to a single party, thus showing a list of all of a party's attached entities.

Class

party_plugin_row_attached_entity
Plugin class for displaying party attached entities with entity_view.

Code

function pre_render($results) {
  $entities_to_load = array();
  $this->entities = array();
  foreach ($results as $index => $result) {
    $entity_type = $result->{$this->field_alias_entity_type};
    $id = $result->{$this->field_alias_eid};

    // We group this first by type.
    $entities_to_load[$entity_type][$index] = $id;
  }
  $this->entities = array();
  foreach ($entities_to_load as $entity_type => $entity_ids) {
    $entities = entity_load($entity_type, $entity_ids);
    $this->entities[$entity_type] = $entities;
  }
}