src/Services/Security/SecurityTools.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Services\Security;
  3. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  4. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  5. use App\Services\LogTools;
  6. class SecurityTools
  7. {
  8.     public function __construct(LogTools $logToolsTokenStorageInterface $tokenStorage)
  9.     {
  10.         $this->logTools $logTools;
  11.         $this->tokenStorage $tokenStorage;
  12.     }
  13.     // In futur version, this code is handled properly in Symfony security class
  14.     public function logout(SessionInterface $session)
  15.     {
  16.         // Invalidate the session
  17.         $session->invalidate();
  18.         // Clear the security token (logout the user)
  19.         $this->tokenStorage->setToken(null);
  20.     }
  21. }