src/Controller/SecurityController.php line 28
<?phpnamespace App\Controller;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\Routing\Annotation\Route;use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;use App\Repository\UserRepository;use Symfony\Component\HttpFoundation\RequestStack;use Doctrine\ORM\EntityManagerInterface;class SecurityController extends AbstractController{/*** @Route("/login", name="app_login")*/public function login(AuthenticationUtils $authenticationUtils, UserRepository $userRepository, RequestStack $requestStack, EntityManagerInterface $em): Response{$error = $authenticationUtils->getLastAuthenticationError();$userEmail = $authenticationUtils->getLastUsername();$session = $requestStack->getSession();if ($userEmail) {$user = $userRepository->findOneBy(['email' => $userEmail]);if ($user) {try {$defaultLanguage = $user->getDefaultLanguage();if ($defaultLanguage && $defaultLanguage->getAbbreviation()) {// Store the abbreviation (locale code) in lowercase for ICU compatibility$session->set('selected_language', strtolower($defaultLanguage->getAbbreviation()));}} catch (\Exception $e) {// Language was deleted, clear the reference using DQL to avoid loading the entity$em->createQuery('UPDATE App\Entity\User uSET u.defaultLanguage = NULLWHERE u.id = :userId')->setParameter('userId', $user->getId())->execute();}}}return $this->render('security/login.html.twig', ['last_username' => $userEmail,'error' => $error,]);}/*** @Route("/logout", name="app_logout")*/public function logout(){throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');}}