Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Controller/Backend/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions templates/users/listing.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
</tbody>
</table>

{{ pager(users, template = '@bolt/helpers/_pager_bootstrap.html.twig', class="justify-content-center") }}

{% endblock %}


Expand Down