You are here

class render_cache_hijack_views_plugin_ds_entity_view 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

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

Enabled for caching via entity_view().

Hierarchy

Expanded class hierarchy of render_cache_hijack_views_plugin_ds_entity_view

1 string reference to 'render_cache_hijack_views_plugin_ds_entity_view'
render_cache_ds_views_plugins_alter in modules/render_cache_ds/views/render_cache_ds.views.inc
Implements hook_views_plugins_alter().

File

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

View source
class render_cache_hijack_views_plugin_ds_entity_view extends views_plugin_ds_entity_view {

  /**
   * 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.
   *
   * @param string $view_mode
   *   The view mode which is set in the Views' options.
   * @param object $row
   *   The current active row object being rendered.
   * @param bool $load_comments
   *
   * @return string
   *   An entity view rendered as HTML
   */
  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;
  }

}

Members