SwitchUserRole.php 1.0 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\Core\Role;
  11. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  12. /**
  13. * SwitchUserRole is used when the current user temporarily impersonates
  14. * another one.
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. */
  18. class SwitchUserRole extends Role
  19. {
  20. private $source;
  21. /**
  22. * @param string $role The role as a string
  23. * @param TokenInterface $source The original token
  24. */
  25. public function __construct($role, TokenInterface $source)
  26. {
  27. parent::__construct($role);
  28. $this->source = $source;
  29. }
  30. /**
  31. * Returns the original Token.
  32. *
  33. * @return TokenInterface The original TokenInterface instance
  34. */
  35. public function getSource()
  36. {
  37. return $this->source;
  38. }
  39. }