<?php
namespace App\Actions\Security;
use App\Forms\Security\LoginType;
use App\Responder\Security\LoginResponder;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;
/**
* Created by PhpStorm.
* User: Christophe Marsaudon
* Class LoginAction
*/
class LoginAction
{
/** @var FormFactoryInterface */
private $formFactory;
/** @var AuthenticationUtils */
private $authenticationUtils;
/**
* {@inheritdoc}
*/
public function __construct(
FormFactoryInterface $formFactory,
AuthenticationUtils $authenticationUtils
) {
$this->formFactory = $formFactory;
$this->authenticationUtils = $authenticationUtils;
}
/**
* @param LoginResponder $responder
*
* @return Response
* @throws LoaderError
* @throws RuntimeError
* @throws SyntaxError
* @Route("/login", name="security_login")
*
*/
public function login(LoginResponder $responder): Response
{
$form = $this->formFactory->create(LoginType::class);
return $responder($form, $this->authenticationUtils->getLastAuthenticationError());
}
}