You are here

protected function PagererParameters::parsePagerer in Pagerer 8.2

Parses a Pagerer pager querystring.

Parameters

string $hash: The hash of the current request.

string $querystring: The value of the querystring parameter identified by ::querystringKey.

1 call to PagererParameters::parsePagerer()
PagererParameters::getPagererItem in src/PagererParameters.php
Returns a Pagerer 'pager item'.

File

src/PagererParameters.php, line 156

Class

PagererParameters
Provides extended pager information contained within the current request.

Namespace

Drupal\pagerer

Code

protected function parsePagerer(string $hash, string $querystring) {
  $items = explode(static::ITEM_SEPARATOR, $querystring);

  // Current pages.
  $tmp = explode(static::VALUE_SEPARATOR, $items[0]);
  foreach ($tmp as $pager_id => $page) {
    $this->pagererItems[$hash]['page'][$pager_id] = $this
      ->pageUrlValueToIndex((int) $page);
  }

  // Current adaptive keys.
  if (isset($items[1]) && $items[1] === 'ak' && isset($items[2])) {
    $tmp = explode(static::VALUE_SEPARATOR, $items[2]);
    foreach ($tmp as $pager_id => $ak) {
      $tmp_0 = explode('_', $ak);
      $this->pagererItems[$hash]['ak'][$pager_id][0] = !empty($tmp_0[0]) ? $this
        ->pageUrlValueToIndex((int) $tmp_0[0]) : NULL;
      $this->pagererItems[$hash]['ak'][$pager_id][1] = isset($tmp_0[1]) ? $this
        ->pageUrlValueToIndex((int) $tmp_0[1]) : NULL;
      if (isset($tmp_0[2])) {
        $this->pagererItems[$hash]['ak'][$pager_id][2] = $this
          ->pageUrlValueToIndex((int) $tmp_0[2]);
      }
    }
  }
}