src/Controller/Admin/SecurityController.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use App\Service\ActivityService;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  9. class SecurityController extends AbstractController
  10. {
  11.     private $entityManager;
  12.     private $activityService;
  13.     public function __construct(EntityManagerInterface $entityManager,ActivityService $activityService)
  14.     {
  15.         $this->entityManager $entityManager;
  16.         $this->activityService $activityService;
  17.     }
  18.     /**
  19.      * @Route("/login", name="app_login")
  20.      */
  21.     public function login(AuthenticationUtils $authenticationUtils): Response
  22.     {
  23.         if ($this->getUser())
  24.            return $this->redirectToRoute('index');
  25.         // get the login error if there is one
  26.         $error $authenticationUtils->getLastAuthenticationError();
  27.         // last username entered by the user
  28.         $lastUsername $authenticationUtils->getLastUsername();
  29.         return $this->render('@admin/security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  30.     }
  31.     /**
  32.      * @Route("/logout", name="app_logout")
  33.      */
  34.     public function logout()
  35.     {
  36.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  37.     }
  38. }