You are here

protected function PagererParameters::getPagererItem in Pagerer 8.2

Returns a Pagerer 'pager item'.

Parse the request and store its values in ::$pagererItems for later faster access.

Parameters

string $item_id: The key in the ::$pagererItems array for the item to be returned.

Return value

mixed|null The 'pager item', or NULL if missing.

1 call to PagererParameters::getPagererItem()
PagererParameters::getPagerQuery in src/PagererParameters.php
Gets the request query parameter.

File

src/PagererParameters.php, line 128

Class

PagererParameters
Provides extended pager information contained within the current request.

Namespace

Drupal\pagerer

Code

protected function getPagererItem(string $item_id) {

  // We calculate an hash of the current request to cater for the case when
  // the querystring changes in different requests on the stack.
  $request = $this->requestStack
    ->getCurrentRequest();
  $hash = hash('md5', (string) $request);
  if (!isset($this->pagererItems[$hash])) {
    if ($this->querystringOverride && $request->query
      ->has($this->querystringKey)) {

      // Overriden URL querystring exists.
      $this
        ->parsePagerer($hash, $request->query
        ->get($this->querystringKey));
    }
    else {

      // No overriden URL querystring exists, try 'page' + 'page_ak'.
      $this
        ->parseLegacy($hash, $request->query
        ->get('page', ''), $request->query
        ->get('page_ak', ''));
    }
  }
  return $this->pagererItems[$hash][$item_id] ?? NULL;
}