diff --git a/src/Controller/Backend/UserController.php b/src/Controller/Backend/UserController.php index 7394c28ca..1f1b279f0 100644 --- a/src/Controller/Backend/UserController.php +++ b/src/Controller/Backend/UserController.php @@ -6,6 +6,9 @@ use Bolt\Controller\TwigAwareController; use Bolt\Repository\UserRepository; +use Bolt\Storage\Query; +use Pagerfanta\Adapter\ArrayAdapter; +use Pagerfanta\Pagerfanta; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -18,6 +21,8 @@ class UserController extends TwigAwareController implements BackendZoneInterface /** @var UserRepository */ private $users; + private const PAGESIZE = 20; + public function __construct(UserRepository $users) { $this->users = $users; @@ -26,9 +31,13 @@ public function __construct(UserRepository $users) /** * @Route("/users", name="bolt_users") */ - public function users(): Response + public function users(Query $query): Response { - $users = $this->users->findBy([], ['username' => 'ASC'], 1000); + $users = new ArrayAdapter($this->users->findBy([], ['username' => 'ASC'], 1000)); + $currentPage = (int) $this->getFromRequest('page', '1'); + $users = new Pagerfanta($users); + $users->setMaxPerPage(self::PAGESIZE) + ->setCurrentPage($currentPage); $twigVars = [ 'title' => 'controller.user.title', diff --git a/templates/users/listing.html.twig b/templates/users/listing.html.twig index 825d5fc3c..fad543ee8 100644 --- a/templates/users/listing.html.twig +++ b/templates/users/listing.html.twig @@ -94,6 +94,8 @@ + {{ pager(users, template = '@bolt/helpers/_pager_bootstrap.html.twig', class="justify-content-center") }} + {% endblock %}