summaryrefslogtreecommitdiff
path: root/src/Controllers/AuthController.php
blob: cdaee1677e150c211976d93d90edcd546cd6325c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

namespace Engelsystem\Controllers;

use Engelsystem\Http\Response;
use Engelsystem\Http\UrlGeneratorInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

class AuthController extends BaseController
{
    /** @var Response */
    protected $response;

    /** @var SessionInterface */
    protected $session;

    /** @var UrlGeneratorInterface */
    protected $url;

    public function __construct(Response $response, SessionInterface $session, UrlGeneratorInterface $url)
    {
        $this->response = $response;
        $this->session = $session;
        $this->url = $url;
    }

    /**
     * @return Response
     */
    public function logout()
    {
        $this->session->invalidate();

        return $this->response->redirectTo($this->url->to('/'));
    }
}