AccountStatusException.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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\Exception;
  11. use Symfony\Component\Security\Core\User\UserInterface;
  12. /**
  13. * AccountStatusException is the base class for authentication exceptions
  14. * caused by the user account status.
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. * @author Alexander <iam.asm89@gmail.com>
  18. */
  19. abstract class AccountStatusException extends AuthenticationException
  20. {
  21. private $user;
  22. /**
  23. * Get the user.
  24. *
  25. * @return UserInterface
  26. */
  27. public function getUser()
  28. {
  29. return $this->user;
  30. }
  31. public function setUser(UserInterface $user)
  32. {
  33. $this->user = $user;
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function __serialize(): array
  39. {
  40. return [$this->user, parent::__serialize()];
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function __unserialize(array $data): void
  46. {
  47. [$this->user, $parentData] = $data;
  48. $parentData = \is_array($parentData) ? $parentData : unserialize($parentData);
  49. parent::__unserialize($parentData);
  50. }
  51. }