LoginController::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 9.4285
1
<?php
2
3
namespace Dominikzogg\EnergyCalculator\Controller;
4
5
use Saxulum\RouteController\Annotation\DI;
6
use Saxulum\RouteController\Annotation\Route;
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\Response;
9
10
/**
11
 * @Route("/{_locale}", asserts={"_locale"="([a-z]{2}|[a-z]{2}_[A-Z]{2})"})
12
 * @DI(serviceIds={
13
 *      "security.last_error",
14
 *      "twig"
15
 * })
16
 */
17
class LoginController
18
{
19
    /**
20
     * @var \Twig_Environment
21
     */
22
    protected $twig;
23
24
    /**
25
     * @var callback
26
     */
27
    protected $securityLastError;
28
29
    public function __construct($securityLastError, \Twig_Environment $twig)
30
    {
31
        $this->securityLastError = $securityLastError;
32
        $this->twig = $twig;
33
    }
34
35
    /**
36
     * @Route("/login", bind="login", method="GET")
37
     */
38
    public function loginAction(Request $request)
39
    {
40
        $securityLastError = $this->securityLastError;
41
42
        // return the rendered template
43
        return $this->render('@DominikzoggEnergyCalculator/Login/login.html.twig', array(
44
            'error'         => $securityLastError($request),
45
            'last_username' => $request->getSession()->get('_security.last_username'),
46
        ));
47
    }
48
49
    /**
50
     * @Route("/logout", bind="logout", method="GET")
51
     */
52
    public function logoutAction()
53
    {
54
    }
55
56
    /**
57
     * @Route("/login_check", bind="login_check", method="POST")
58
     */
59
    public function logincheckAction()
60
    {
61
    }
62
63
    /**
64
     * @param $view
65
     * @param  array    $parameters
66
     * @return Response
67
     */
68
    protected function render($view, array $parameters = array())
69
    {
70
        return new Response($this->twig->render($view, $parameters));
71
    }
72
}
73