Completed
Pull Request — master (#10)
by Matze
07:31
created

Session::processResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 2
crap 2
1
<?php
2
3
namespace BrainExe\Core\Middleware;
4
5
use BrainExe\Annotations\Annotations\Inject;
6
use BrainExe\Core\Annotations\Middleware;
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\Response;
9
use Symfony\Component\HttpFoundation\Session\Session as SessionModel;
10
use Symfony\Component\Routing\Route;
11
12
/**
13
 * @Middleware("Middleware.Session")
14
 */
15
class Session extends AbstractMiddleware
16
{
17
18
    /**
19
     * @var SessionModel
20
     */
21
    private $session;
22
23
    /**
24
     * @Inject({"@RedisSession"})
25
     * @param SessionModel $session
26
     */
27
    public function __construct(SessionModel $session)
28
    {
29
        $this->session = $session;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function processRequest(Request $request, Route $route)
36
    {
37
        $request->setSession($this->session);
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function processResponse(Request $request, Response $response)
44
    {
45
        $this->session->save();
46
    }
47
}
48