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

CustomerLogoutHandler   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A logout() 0 12 4
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