Files
myep-team/src/Controller/Admin/Teamer/IndexController.php
T
2023-10-25 09:37:40 +02:00

49 lines
1.5 KiB
PHP

<?php
namespace App\Controller\Admin\Teamer;
use App\Repository\TeamerRepository;
use App\Service\Common\TeamerFilterHandler;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class IndexController extends AbstractController
{
public function __construct(
protected readonly TeamerFilterHandler $filterHandler,
private readonly TeamerRepository $teamerRepository,
private readonly PaginatorInterface $paginator
) {
}
#[Route('/admin/teamer', name: 'app_admin_teamer_index')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): Response
{
$filterDto = $this->filterHandler->getFilterSettings();
$query = $this
->teamerRepository
->getListQuery($filterDto)
;
$pagination = $this->paginator->paginate(
$query,
$request->query->getInt('page', 1),
10,
[
'defaultSortFieldName' => 'teamer.lastName',
'defaultSortDirection' => 'asc',
]
);
return $this->render('admin/teamer/index.html.twig', [
'pagination' => $pagination,
'filterDto' => $filterDto,
]);
}
}