SwitchUserEvent.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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\Event;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  13. use Symfony\Component\Security\Core\User\UserInterface;
  14. use Symfony\Contracts\EventDispatcher\Event;
  15. /**
  16. * SwitchUserEvent.
  17. *
  18. * @author Fabien Potencier <fabien@symfony.com>
  19. */
  20. final class SwitchUserEvent extends Event
  21. {
  22. private $request;
  23. private $targetUser;
  24. private $token;
  25. public function __construct(Request $request, UserInterface $targetUser, TokenInterface $token = null)
  26. {
  27. $this->request = $request;
  28. $this->targetUser = $targetUser;
  29. $this->token = $token;
  30. }
  31. public function getRequest(): Request
  32. {
  33. return $this->request;
  34. }
  35. public function getTargetUser(): UserInterface
  36. {
  37. return $this->targetUser;
  38. }
  39. public function getToken(): ?TokenInterface
  40. {
  41. return $this->token;
  42. }
  43. public function setToken(TokenInterface $token)
  44. {
  45. $this->token = $token;
  46. }
  47. }