PagersCacheContext.php in Drupal 8
File
core/lib/Drupal/Core/Cache/Context/PagersCacheContext.php
View source
<?php
namespace Drupal\Core\Cache\Context;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Pager\PagerParametersInterface;
class PagersCacheContext implements CalculatedCacheContextInterface {
use DeprecatedServicePropertyTrait;
protected $deprecatedProperties = [
'requestStack' => 'request_stack',
];
protected $pagerParams;
public function __construct($pager_params) {
if (!$pager_params instanceof PagerParametersInterface) {
@trigger_error('Calling ' . __METHOD__ . ' with a $pager_params argument that does not implement \\Drupal\\Core\\Pager\\PagerParametersInterface is deprecated in drupal:8.8.0 and is required in drupal:9.0.0. See https://www.drupal.org/node/2779457', E_USER_DEPRECATED);
$pager_params = \Drupal::service('pager.parameters');
}
$this->pagerParams = $pager_params;
}
public static function getLabel() {
return t('Pager');
}
public function getContext($pager_id = NULL) {
if ($pager_id === NULL) {
return $this->pagerParams
->getPagerParameter();
}
return $pager_id . '.' . $this->pagerParams
->findPage($pager_id);
}
public function getCacheableMetadata($pager_id = NULL) {
return new CacheableMetadata();
}
}