Completed
Pull Request — 4.0 (#4082)
by akira
07:49
created

CustomerLogoutHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Eccube\Security\Http\Logout;
4
5
use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
9
use Symfony\Component\HttpFoundation\Session\SessionInterface;
10
11
class CustomerLogoutHandler implements LogoutHandlerInterface{
12
13
    private $session;
14
    
15
    public function __construct(SessionInterface $session)
16
    {
17
        $this->session = $session;
18
    }
19
    
20
    public function logout(Request $request, Response $response, TokenInterface $token)
21
    {
22
        if($sessions = $this->session->all()) {
23
            unset($sessions["_security_admin"]);
24
            
25
            foreach ($sessions as $key => $value) {
26
                if($this->session->has($key)) {
27
                    $this->session->remove($key);
28
                }
29
            }
30
        }
31
    }
32
33
}
34