Open insekticid opened 6 years ago
Sometimes you do not want to show all pages based on results count.
<?php declare(strict_types=1); namespace App\Util; use Pagerfanta\Pagerfanta; use function min; class LimitedPagerfanta extends Pagerfanta { /** * @var int */ private $limitedPageNumber; public function setLimitedPageNumber(int $limitedPageNumber) : LimitedPagerfanta { $this->limitedPageNumber = $limitedPageNumber; return $this; } public function getNbResults() : int { $results = parent::getNbResults(); return (int) min($results, $this->limitedPageNumber * $this->getMaxPerPage()); } }
Sometimes it needed, but it is better to decorate adapter.
Thanks for your input, @Koc. Do you have any code examples of how you've done this?
@sampart see #261
Thanks, @Koc.
Sometimes you do not want to show all pages based on results count.