public function handle(GetResponseEvent $event)
    {
        $request = $event->getRequest();

        $response = $this->successHandler->onLogoutSuccess($request);
        if (!$response instanceof Response) {
            throw new \RuntimeException('Logout Success Handler did not return a Response.');
        }

        // handle multiple logout attempts gracefully
        if (null !== $token = $this->securityContext->getToken()) {
            foreach ($this->handlers as $handler) {
                $handler->logout($request, $response, $token);
            }
        }

        $this->securityContext->setToken(null);
        $event->setResponse($response);
    }
public function handle(GetResponseEvent $event)
    {
        $request = $event->getRequest();

        $response = $this->successHandler->onLogoutSuccess($request);
        if (!$response instanceof Response) {
            throw new \RuntimeException('Logout Success Handler did not return a Response.');
        }

        // handle multiple logout attempts gracefully
        if (null !== $token = $this->securityContext->getToken()) {
            foreach ($this->handlers as $handler) {
                $handler->logout($request, $response, $token);
            }
        }

        $this->securityContext->setToken(null);
        $event->setResponse($response);
    }
public function handle ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ response = $ this -> successHandler -> onLogoutSuccess ( $ request ) ; if ( ! $ response instanceof Response ) { throw new \ RuntimeException ( 'Logout Success Handler did not return a Response.' ) ; } // handle multiple logout attempts gracefully if ( null !== $ token = $ this -> securityContext -> getToken ( ) ) { foreach ( $ this -> handlers as $ handler ) { $ handler -> logout ( $ request , $ response , $ token ) ; } } $ this -> securityContext -> setToken ( null ) ; $ event -> setResponse ( $ response ) ; }
Performs the logout if requested.

@param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event A GetResponseEvent instance

@throws RuntimeException if the LogoutSuccessHandlerInterface instance does not return a response
Performs the logout if requested .