49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\Admin\Assignment;
|
|
|
|
use App\Repository\AssignmentRepository;
|
|
use App\Service\Common\AssignmentFilterHandler;
|
|
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 IndexController extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private readonly AssignmentRepository $assignmentRepository,
|
|
private readonly PaginatorInterface $paginator,
|
|
private readonly AssignmentFilterHandler $filterHandler
|
|
) {
|
|
}
|
|
|
|
#[Route('/admin/assignment', name: 'app_admin_assignment_index')]
|
|
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
|
public function index(Request $request): Response
|
|
{
|
|
$filterDto = $this->filterHandler->getFilterSettings();
|
|
|
|
$query = $this
|
|
->assignmentRepository
|
|
->getListQuery($filterDto)
|
|
;
|
|
|
|
$pagination = $this->paginator->paginate(
|
|
$query,
|
|
$request->query->getInt('page', 1),
|
|
10,
|
|
[
|
|
'defaultSortFieldName' => 'destination.dateFrom',
|
|
'defaultSortDirection' => 'asc',
|
|
]
|
|
);
|
|
|
|
return $this->render('admin/assignment/index.html.twig', [
|
|
'pagination' => $pagination,
|
|
'filterDto' => $filterDto,
|
|
]);
|
|
}
|
|
} |