You are here

public static function Pager::preRenderPager in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Render/Element/Pager.php \Drupal\Core\Render\Element\Pager::preRenderPager()
  2. 9 core/lib/Drupal/Core/Render/Element/Pager.php \Drupal\Core\Render\Element\Pager::preRenderPager()

#pre_render callback to associate the appropriate cache context.

Parameters

array $pager: A renderable array of #type => pager.

Return value

array

File

core/lib/Drupal/Core/Render/Element/Pager.php, line 69

Class

Pager
Provides a render element for a pager.

Namespace

Drupal\Core\Render\Element

Code

public static function preRenderPager(array $pager) {

  // Note: the default pager theme process function
  // template_preprocess_pager() also calls
  // \Drupal\Core\Pager\PagerManagerInterface::getUpdatedParameters(), which
  // maintains the existing query string. Therefore
  // template_preprocess_pager() adds the 'url.query_args' cache context,
  // which causes the more specific cache context below to be optimized away.
  // In other themes, however, that may not be the case.
  $pager['#cache']['contexts'][] = 'url.query_args.pagers:' . $pager['#element'];
  return $pager;
}