pagination

This commit is contained in:
2024-07-31 14:26:26 +03:00
parent d6d703aaa6
commit 1714afcf3f
4 changed files with 40 additions and 7 deletions

View File

@ -14,17 +14,18 @@ class Pagination
private string $baseUrl;
public function __construct($countItem, $perPage, $currentPage, $baseUrl)
// public function __construct($countItem, $perPage, $currentPage, $baseUrl)
public function __construct(int $countItem, array $params, string $baseUrl)
{
$this->countItem = $countItem;
$this->perPage = $perPage;
$this->currentPage = $currentPage;
$this->perPage = $params['perPage'];
$this->currentPage = $params['currentPage'];
$this->baseUrl = $baseUrl;
$this->countPages = ceil($this->countItem / $perPage);
$this->countPages = ceil($this->countItem / $this->perPage);
}
public function create()
public function create(): void
{
$prev = $this->currentPage - 1 >= 1 ? $this->currentPage - 1 : null;
$next = $this->currentPage + 1 <= $this->countPages ? $this->currentPage + 1 : null;
@ -42,12 +43,17 @@ class Pagination
echo $this->html;
}
public function fetch()
public function fetch(): string
{
return $this->html;
}
private function getTemplate()
public function hookBefore(): void
{
}
private function getTemplate(): string
{
return '<nav aria-label="Page navigation example">
<ul class="pagination">