src/Controller/Management/Office/Select/ListController.php line 23

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controller\Management\Office\Select;
  4. use App\Entity\Office\Office;
  5. use App\Service\Management\Office\OfficeSelectionService;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. #[Route(path'/offices')]
  11. class ListController extends AbstractController
  12. {
  13.     public function __construct(
  14.         private OfficeSelectionService $officeSelectionService,
  15.     ) {}
  16.     #[Route(path'/list'name'management_office_list')]
  17.     public function list(): Response
  18.     {
  19.         return $this->render('management/office/list.html.twig');
  20.     }
  21.     #[Route(path'/select/{office}'name'management_office_select'methods'POST')]
  22.     public function select(Request $requestOffice $office): Response
  23.     {
  24.         $csrf $request->get('token');
  25.         if ($this->isCsrfTokenValid('office-selection'$csrf)) {
  26.             $this->officeSelectionService->setSelectedOffice($office);
  27.         }
  28.         return $this->redirectToRoute('management_dashboard');
  29.     }
  30. }