getQuery() ->setFirstResult($limit * ($page - 1)) ->setMaxResults($limit); $this->total = $paginator->count(); $this->lastPage = (int) ceil($paginator->count() / $paginator->getQuery()->getMaxResults()); $this->items = $paginator; $this->currentPage = $page; $this->limit = $limit; return $this; } public function getTotal(): int { return $this->total; } public function getLastPage(): int { return $this->lastPage; } public function getItems() { return $this->items; } public function getShowing() { $showingStart = ($this->currentPage - 1) * $this->limit; $showingEnd = $showingStart + $this->limit; return sprintf("Showing %d - %d of %d results.", $showingStart, $showingEnd, $this->total); } }