function Pager::preRenderPager
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Render/Element/Pager.php \Drupal\Core\Render\Element\Pager::preRenderPager()
- 10 core/lib/Drupal/Core/Render/Element/Pager.php \Drupal\Core\Render\Element\Pager::preRenderPager()
- 9 core/lib/Drupal/Core/Render/Element/Pager.php \Drupal\Core\Render\Element\Pager::preRenderPager()
- 8.9.x core/lib/Drupal/Core/Render/Element/Pager.php \Drupal\Core\Render\Element\Pager::preRenderPager()
Render API callback: Associates the appropriate cache context.
This function is assigned as a #pre_render callback.
Parameters
array $pager: A renderable array of #type => pager.
Return value
array The render array with cache contexts added.
File
-
core/
lib/ Drupal/ Core/ Render/ Element/ Pager.php, line 75
Class
- Pager
- Provides a render element for a pager.
Namespace
Drupal\Core\Render\ElementCode
public static function preRenderPager(array $pager) {
// Note: the default pager theme preprocess function
// \Drupal\Core\Pager\PagerPreprocess::preprocessPager() also calls
// \Drupal\Core\Pager\PagerManagerInterface::getUpdatedParameters(), which
// maintains the existing query string. Therefore
// \Drupal\Core\Pager\PagerPreprocess::preprocessPager() 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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.