protected function PagererStyleBase::getNavigationItem in Pagerer 8
Same name and namespace in other branches
- 8.2 src/Plugin/pagerer/PagererStyleBase.php \Drupal\pagerer\Plugin\pagerer\PagererStyleBase::getNavigationItem()
Gets a link/button item to first/previous/next/last link.
Parameters
string $scope: Target page [first|previous|next|last].
bool $href: Whether the item should contain the pager link.
Return value
array Render array.
2 calls to PagererStyleBase::getNavigationItem()
- PagererStyleBase::preprocess in src/
Plugin/ pagerer/ PagererStyleBase.php - Prepares to render the pager.
- Scrollpane::buildPagerItems in src/
Plugin/ pagerer/ Scrollpane.php - Return the pager render array.
File
- src/
Plugin/ pagerer/ PagererStyleBase.php, line 626
Class
- PagererStyleBase
- Base plugin for Pagerer.
Namespace
Drupal\pagerer\Plugin\pagererCode
protected function getNavigationItem($scope, $href = TRUE) {
// Determine the offset to current page and whether the link is
// active or not.
switch ($scope) {
case 'first':
$offset = -$this->pager
->getCurrentPage();
break;
case 'previous':
$offset = $this->pager
->getCurrentPage() == 0 ? 0 : -1;
break;
case 'next':
$offset = $this->pager
->getCurrentPage() == $this->pager
->getLastPage() ? 0 : 1;
break;
case 'last':
$offset = $this->pager
->getLastPage() - $this->pager
->getCurrentPage();
break;
}
// Format the page text and HTML title, used by the browser to display
// microhelp text.
$ret = [
'text' => $this
->getDisplayTag($scope, $offset),
'title' => $this
->getDisplayTag($scope . '_title', $offset),
'reader_text' => $this
->getDisplayTag($scope . '_reader', $offset),
'attributes' => new Attribute(),
];
// Get the destination URL link if neeeded.
if ($href) {
$ret['href'] = $this->pager
->getHref($this->parameters, $this->pager
->getCurrentPage() + $offset);
}
return $ret;
}