mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-16 15:24:26 +00:00
56 lines
985 B
PHP
56 lines
985 B
PHP
<?php
|
|
|
|
/**
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Chill\MainBundle\Pagination;
|
|
|
|
use Iterator;
|
|
|
|
/**
|
|
* PageGenerator associated with a Paginator.
|
|
*/
|
|
class PageGenerator implements Iterator
|
|
{
|
|
protected int $current = 1;
|
|
|
|
protected Paginator $paginator;
|
|
|
|
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 0 < $this->current
|
|
&& $this->paginator->countPages() >= $this->current;
|
|
}
|
|
}
|