src/Actions/Security/LoginAction.php line 52

Open in your IDE?
  1. <?php
  2. namespace App\Actions\Security;
  3. use App\Forms\Security\LoginType;
  4. use App\Responder\Security\LoginResponder;
  5. use Symfony\Component\Form\FormFactoryInterface;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  9. use Twig\Error\LoaderError;
  10. use Twig\Error\RuntimeError;
  11. use Twig\Error\SyntaxError;
  12. /**
  13.  * Created by PhpStorm.
  14.  * User: Christophe Marsaudon
  15.  * Class LoginAction
  16.  */
  17. class LoginAction
  18. {
  19.     /** @var FormFactoryInterface  */
  20.     private $formFactory;
  21.     /** @var AuthenticationUtils */
  22.     private $authenticationUtils;
  23.     /**
  24.      * {@inheritdoc}
  25.      */
  26.     public function __construct(
  27.         FormFactoryInterface $formFactory,
  28.         AuthenticationUtils $authenticationUtils
  29.     ) {
  30.         $this->formFactory $formFactory;
  31.         $this->authenticationUtils $authenticationUtils;
  32.     }
  33.     /**
  34.      * @param LoginResponder $responder
  35.      *
  36.      * @return Response
  37.      * @throws LoaderError
  38.      * @throws RuntimeError
  39.      * @throws SyntaxError
  40.      * @Route("/login", name="security_login")
  41.      *
  42.      */
  43.     public function login(LoginResponder $responder): Response
  44.     {
  45.         $form $this->formFactory->create(LoginType::class);
  46.         return $responder($form$this->authenticationUtils->getLastAuthenticationError());
  47.     }
  48. }