DefaultLogoutSuccessHandler.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. }