You are here

class AuthcacheViewsFragment in Authenticated User Page Caching (Authcache) 7.2

Personalization fragment for rendered views.

Hierarchy

Expanded class hierarchy of AuthcacheViewsFragment

1 string reference to 'AuthcacheViewsFragment'
authcache_views_authcache_p13n_fragment in modules/authcache_views/authcache_views.module
Implements hook_authcache_p13n_fragment().

File

modules/authcache_views/includes/AuthcacheViewsFragment.inc, line 10
Defines personalization fragment for views

View source
class AuthcacheViewsFragment implements AuthcacheP13nFragmentInterface, AuthcacheP13nFragmentLoaderInterface, AuthcacheP13nFragmentAccessInterface {
  protected $viewName;
  protected $displayName;

  /**
   * Construct new view fragment.
   *
   * @param string $view_name
   *   The view name.
   * @param string $display_name
   *   The name of the display of the specified view.
   */
  public function __construct($view_name, $display_name) {
    $this->viewName = $view_name;
    $this->displayName = $display_name;
  }

  /**
   * {@inheritdoc}
   */
  public function load($params, $context) {
    $view = views_get_view($this->viewName);
    if (!$view) {
      throw new AuthcacheP13nRequestNotFound();
    }
    if (!$view
      ->set_display($this->displayName)) {
      throw new AuthcacheP13nRequestNotFound();
    }
    if (!empty($context['views arguments'])) {
      $view
        ->set_arguments($context['views arguments']);
    }
    return array(
      $this->viewName => $view,
    );
  }

  /**
   * {@inheritdoc}
   */
  public function check($account, $view_name, $view, $context) {
    return $view
      ->access(array(
      $view->current_display,
    ), $account);
  }

  /**
   * {@inheritdoc}
   *
   * @see views_embed_view()
   */
  public function render($view_name, $view, $context) {
    return $view
      ->preview();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AuthcacheViewsFragment::$displayName protected property
AuthcacheViewsFragment::$viewName protected property
AuthcacheViewsFragment::check public function Check whether the user has access to the given fragment. Overrides AuthcacheP13nFragmentAccessInterface::check
AuthcacheViewsFragment::load public function Load the objects designated by the given list of keys. Overrides AuthcacheP13nFragmentLoaderInterface::load
AuthcacheViewsFragment::render public function Overrides AuthcacheP13nFragmentInterface::render
AuthcacheViewsFragment::__construct public function Construct new view fragment.