function PagersCacheContext::getContext

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Cache/Context/PagersCacheContext.php \Drupal\Core\Cache\Context\PagersCacheContext::getContext()
  2. 8.9.x core/lib/Drupal/Core/Cache/Context/PagersCacheContext.php \Drupal\Core\Cache\Context\PagersCacheContext::getContext()
  3. 10 core/lib/Drupal/Core/Cache/Context/PagersCacheContext.php \Drupal\Core\Cache\Context\PagersCacheContext::getContext()

Overrides CalculatedCacheContextInterface::getContext

See also

\Drupal\Core\Pager\PagerParametersInterface::findPage()

File

core/lib/Drupal/Core/Cache/Context/PagersCacheContext.php, line 46

Class

PagersCacheContext
Defines a cache context for "per page in a pager" caching.

Namespace

Drupal\Core\Cache\Context

Code

public function getContext($pager_id = NULL) {
    // The value of the 'page' query argument contains the information that
    // controls *all* pagers.
    if ($pager_id === NULL) {
        return $this->pagerParams
            ->getPagerParameter();
    }
    return $pager_id . '.' . $this->pagerParams
        ->findPage($pager_id);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.