vendor/symfony/security-http/Logout/DefaultLogoutSuccessHandler.php line 18

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Security\Http\Logout;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\Security\Http\EventListener\DefaultLogoutListener;
  13. use Symfony\Component\Security\Http\HttpUtils;
  14. trigger_deprecation('symfony/security-http', '5.1', 'The "%s" class is deprecated, use "%s" instead.', DefaultLogoutSuccessHandler::class, DefaultLogoutListener::class);
  15. /**
  16. * Default logout success handler will redirect users to a configured path.
  17. *
  18. * @author Fabien Potencier <fabien@symfony.com>
  19. * @author Alexander <iam.asm89@gmail.com>
  20. *
  21. * @deprecated since Symfony 5.1
  22. */
  23. class DefaultLogoutSuccessHandler implements LogoutSuccessHandlerInterface
  24. {
  25. protected $httpUtils;
  26. protected $targetUrl;
  27. public function __construct(HttpUtils $httpUtils, string $targetUrl = '/')
  28. {
  29. $this->httpUtils = $httpUtils;
  30. $this->targetUrl = $targetUrl;
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function onLogoutSuccess(Request $request)
  36. {
  37. return $this->httpUtils->createRedirectResponse($request, $this->targetUrl);
  38. }
  39. }