You are here

protected function PagererManager::adaptiveKeysToUrl in Pagerer 8.2

Returns an adaptive keys fragment for use on the URL.

Parameters

int[] $ak: The adaptive keys array, in the format 'L,R,X', where L is the adaptive lock to left page, R is the adaptive lock to right page, and X is the adaptive center lock for calculation of neighborhood.

int $last_page: The last page of the queryset.

Return value

string|null The 0-based or 1-based adaptive keys fragment, depending on the configuration.

1 call to PagererManager::adaptiveKeysToUrl()
PagererManager::getPagererUpdatedParameters in src/PagererManager.php
Gets the URL query parameter array of a pager link.

File

src/PagererManager.php, line 193

Class

PagererManager
Provides a manager for Pagerer, as an extension of core's PagerManager.

Namespace

Drupal\pagerer

Code

protected function adaptiveKeysToUrl(array $ak, int $last_page) {
  if (empty($ak)) {
    return NULL;
  }
  if (!isset($ak[2]) && ($ak[0] ?? 0) === 0 && ($ak[1] ?? $last_page) === $last_page) {
    return NULL;
  }
  $tmp[0] = $this
    ->pageIndexToUrl($ak[0] ?? 0);
  $tmp[1] = $this
    ->pageIndexToUrl($ak[1] ?? $last_page);
  if (isset($ak[2])) {
    $tmp[2] = $this
      ->pageIndexToUrl($ak[2]);
  }
  return implode($this->querystringOverride ? '_' : '.', $tmp);
}