You are here

function render_cache_hijack_views_plugin_ds_entity_view::ds_views_row_render_entity in Render cache 7

Same name and namespace in other branches
  1. 7.2 modules/utility/render_cache_ds/views/plugins/render_cache_hijack_views_plugin_ds_entity_view.inc \render_cache_hijack_views_plugin_ds_entity_view::ds_views_row_render_entity()

Overrides views_plugin_ds_entity_view::ds_views_row_render_entity().

@todo Ask DS to provide a method to return the render function and override it here.

Parameters

string $view_mode: The view mode which is set in the Views' options.

object $row: The current active row object being rendered.

bool $load_comments:

Return value

string An entity view rendered as HTML

File

modules/render_cache_ds/views/plugins/render_cache_hijack_views_plugin_ds_entity_view.inc, line 30
Contains the display suite row style plugin hijack for caching.

Class

render_cache_hijack_views_plugin_ds_entity_view
Plugin which defines the view mode on the resulting entity object.

Code

function ds_views_row_render_entity($view_mode, $row, $load_comments) {

  // Save the original base table.
  $original_base_table = $this->base_table;

  // Override the base table as that will change the render function being called.
  $this->base_table = 'render_cache_' . $this->base_table;

  // This context is created by the parent function _after_ rendering.
  // We need to provide the context for caching purposes within the entity.
  $context = array(
    'row' => $row,
    'view' => &$this->view,
    'view_mode' => $view_mode,
    'load_comments' => $load_comments,
  );
  $this->entities[$row->{$this->field_alias}]->render_cache_ds_context = $context;

  // Call the original function
  $output = parent::ds_views_row_render_entity($view_mode, $row, $load_comments);

  // And restore the base table again,
  $this->base_table = $original_base_table;
  return $output;
}