Completed
Push — master ( 396eea...74cb0e )
by David
03:13
created

Http/Logout/ContextInvalidationLogoutHandler.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of the FOSHttpCacheBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\HttpCacheBundle\Security\Http\Logout;
13
14
use FOS\HttpCacheBundle\UserContextInvalidator;
15
use Symfony\Component\HttpFoundation\Request;
16
use Symfony\Component\HttpFoundation\Response;
17
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
18
use Symfony\Component\Security\Http\Event\LogoutEvent;
19
use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface;
20
21
/**
22
 * @deprecated use ContextInvalidationSessionLogoutHandler in this same namespace as a replacement
23
 *
24
 * This handler is deprecated because it never did what it was supposed to do. The session is already invalidated by the SessionLogoutHandler
25
 * which is always the first logout handler executed
26
 */
27
final class ContextInvalidationLogoutHandler implements LogoutHandlerInterface
0 ignored issues
show
Deprecated Code introduced by
The interface Symfony\Component\Securi...\LogoutHandlerInterface has been deprecated with message: since Symfony 5.1

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
28
{
29
    private $invalidator;
30
31
    public function __construct(UserContextInvalidator $invalidator)
32
    {
33
        $this->invalidator = $invalidator;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function logout(Request $request, Response $response, TokenInterface $token)
40
    {
41
        @trigger_error('Using the ContextInvalidationLogoutHandler is deprecated', E_USER_DEPRECATED);
42
43
        if (class_exists(LogoutEvent::class)) {
44
            // This class no longer works at all with Symfony 5.1, force usage of ContextInvalidationSessionLogoutHandler instead
45
            // See also: https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/pull/545#discussion_r465089219
46
            throw new \LogicException(__CLASS__.'::'.__METHOD__.' no longer works with Symfony 5.1. Remove fos_http_cache.user_context.logout_handler from your firewall configuration. See the changelog for version 2.2. for more information.');
47
        }
48
49
        $this->invalidator->invalidateContext($request->getSession()->getId());
50
    }
51
}
52