You are here

public function PagersCacheContext::getContext in Drupal 9

Same name and namespace in other branches
  1. 8 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);
}