public static function Pager::preRenderPager

public static Pager::preRenderPager(array $pager)

#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 pager_query_add_page(), 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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element!Pager.php/function/Pager::preRenderPager/8.1.x