public function testGetsPagesInRangeForLastPage() { $this->paginator->setCurrentPageNumber(11); $actual = $this->_scrollingStyle->getPages($this->paginator); $expected = array_combine(range(7, 11), range(7, 11)); $this->assertEquals($expected, $actual); }
/** * Returns an array of "local" pages given a page number and range. * * @param Paginator $paginator * @param int $pageRange Unused * @return array */ public function getPages(Paginator $paginator, $pageRange = null) { $pageRange = $paginator->getPageRange(); $pageNumber = $paginator->getCurrentPageNumber(); $originalPageRange = $pageRange; $pageRange = $pageRange * 2 - 1; if ($originalPageRange + $pageNumber - 1 < $pageRange) { $pageRange = $originalPageRange + $pageNumber - 1; } elseif ($originalPageRange + $pageNumber - 1 > count($paginator)) { $pageRange = $originalPageRange + count($paginator) - $pageNumber; } return parent::getPages($paginator, $pageRange); }