src/Controller/LoginController.php line 38

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Reporting;
  4. use App\Repository\ReportingRepository;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  10. class LoginController extends AbstractController
  11. {
  12.     public function menu(int $activestring $subActive '')
  13.     {
  14.         return $this->render('default/menu.html.twig', [
  15.             'active'    => $active,
  16.             'subActive' => $subActive
  17.         ]);
  18.     }
  19.     #[Route('/logout'name'app_logout')]
  20.     public function logout(): void
  21.     {
  22.         throw new \Exception('Don\'t forget to activate logout in security.yaml');
  23.     }
  24.     #[Route('/login'name'login')]
  25.     public function index(Request $requestAuthenticationUtils $authenticationUtils): Response
  26.     {
  27.         $error $authenticationUtils->getLastAuthenticationError();
  28.         $lastEmail $authenticationUtils->getLastUsername();
  29.        /**
  30.         * @var ReportingRepository
  31.         */
  32.         $reportingRepository $this->getDoctrine()->getManager()->getRepository(Reporting::class);
  33.         $reporting $request->get('reporting') ?  $reportingRepository->find$request->get('reporting')) : $reportingRepository->findOneBy(['state' => 0], ['id' => 'DESC']);
  34.         return $this->render('login/index.html.twig', [
  35.             'last_email'    =>  $lastEmail,
  36.             'error'         =>  $error,
  37.             'reportings'     => $reportingRepository->findAll(),
  38.             'reporting'     => $reporting,
  39.             'stats'         => $reporting $reportingRepository->findStatsByTown($reporting->getId()) : []
  40.         ]);
  41.     }
  42.     
  43. }