DefaultLogoutSuccessHandler.php 1.1 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\HttpUtils;
  13. /**
  14. * Default logout success handler will redirect users to a configured path.
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. * @author Alexander <iam.asm89@gmail.com>
  18. */
  19. class DefaultLogoutSuccessHandler implements LogoutSuccessHandlerInterface
  20. {
  21. protected $httpUtils;
  22. protected $targetUrl;
  23. /**
  24. * @param HttpUtils $httpUtils
  25. * @param string $targetUrl
  26. */
  27. public function __construct(HttpUtils $httpUtils, $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. }