Files
myep-team/src/Controller/Administrative/Teamer/RecentAssignmentsController.php
T

47 lines
1.5 KiB
PHP

<?php
namespace App\Controller\Administrative\Teamer;
use App\Entity\Teamer;
use App\Repository\DispositionRepository;
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\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class RecentAssignmentsController extends AbstractController
{
public function __construct(
private readonly DispositionRepository $dispositionRepository,
private readonly PaginatorInterface $paginator
) {
}
#[Route('/administrative/teamer/recent-assignments/{uuid}', name: 'app_administrative_teamer_recent_assignments')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Teamer $teamer, Request $request): Response
{
$query = $this
->dispositionRepository
->getRecentDispositionsByTeamerQuery($teamer)
;
$pagination = $this->paginator->paginate(
$query,
$request->query->getInt('page', 1),
10,
[
'defaultSortFieldName' => 'destination.dateFrom',
'defaultSortDirection' => 'asc',
]
);
return $this->render('administrative/teamer/recent_assignments.html.twig', [
'teamer' => $teamer,
'pagination' => $pagination,
]);
}
}