Completed
Pull Request — master (#2737)
by Jeroen
17:30 queued 02:36
created

SecurityController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A loginAction() 0 10 1
A logoutAction() 0 4 1
1
<?php
2
3
namespace Kunstmaan\AdminBundle\Controller\Authentication;
4
5
use Symfony\Component\HttpFoundation\Response;
6
use Symfony\Component\Routing\Annotation\Route;
7
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
8
use Twig\Environment;
9
10
final class SecurityController
11
{
12
    /** @var AuthenticationUtils */
13
    private $authenticationUtils;
14
    /** @var Environment */
15
    private $twig;
16
17
    public function __construct(AuthenticationUtils $authenticationUtils, Environment $twig)
18
    {
19
        $this->authenticationUtils = $authenticationUtils;
20
        $this->twig = $twig;
21
    }
22
23
    /**
24
     * @Route("/login", name="cms_login", methods={"GET", "POST"})
25
     * @Route("/login", name="fos_user_security_login", methods={"GET", "POST"})
26
     */
27
    public function loginAction()
28
    {
29
        $error = $this->authenticationUtils->getLastAuthenticationError();
30
        $lastUsername = $this->authenticationUtils->getLastUsername();
31
32
        return new Response($this->twig->render('@KunstmaanAdmin/authentication/login.html.twig', [
33
            'last_username' => $lastUsername,
34
            'error' => $error,
35
        ]));
36
    }
37
38
    /**
39
     * @Route("/logout", name="cms_logout")
40
     * @Route("/logout", name="fos_user_security_logout")
41
     */
42
    public function logoutAction()
43
    {
44
        throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
45
    }
46
}
47