mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
47 lines
791 B
PHP
47 lines
791 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Chill\MainBundle\Pagination;
|
|
|
|
/**
|
|
* PageGenerator associated with a Paginator.
|
|
*/
|
|
class PageGenerator implements \Iterator
|
|
{
|
|
protected Paginator $paginator;
|
|
|
|
protected int $current = 1;
|
|
|
|
public function __construct(Paginator $paginator)
|
|
{
|
|
$this->paginator = $paginator;;
|
|
}
|
|
|
|
public function current()
|
|
{
|
|
return $this->paginator->getPage($current);
|
|
}
|
|
|
|
public function key()
|
|
{
|
|
return $this->current;
|
|
}
|
|
|
|
public function next()
|
|
{
|
|
$this->current++;
|
|
}
|
|
|
|
public function rewind()
|
|
{
|
|
$this->current = 1;
|
|
}
|
|
|
|
public function valid()
|
|
{
|
|
return $this->current > 0
|
|
&& $this->current <= $this->paginator->countPages();
|
|
}
|
|
}
|