mirror of
https://github.com/shlinkio/shlink.git
synced 2026-02-28 12:13:13 +08:00
33 lines
797 B
PHP
33 lines
797 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Shlinkio\Shlink\Common\Paginator\Util;
|
|
|
|
use Zend\Paginator\Paginator;
|
|
use Zend\Stdlib\ArrayUtils;
|
|
|
|
trait PaginatorUtilsTrait
|
|
{
|
|
protected function serializePaginator(Paginator $paginator)
|
|
{
|
|
return [
|
|
'data' => ArrayUtils::iteratorToArray($paginator->getCurrentItems()),
|
|
'pagination' => [
|
|
'currentPage' => $paginator->getCurrentPageNumber(),
|
|
'pagesCount' => $paginator->count(),
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Checks if provided paginator is in last page
|
|
*
|
|
* @param Paginator $paginator
|
|
* @return bool
|
|
*/
|
|
protected function isLastPage(Paginator $paginator)
|
|
{
|
|
return $paginator->getCurrentPageNumber() >= $paginator->count();
|
|
}
|
|
}
|