vendor/symfony/security-core/Exception/UserNotFoundException.php line 20

Open in your IDE?
  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. /**
  12.  * UserNotFoundException is thrown if a User cannot be found for the given identifier.
  13.  *
  14.  * @author Fabien Potencier <fabien@symfony.com>
  15.  * @author Alexander <iam.asm89@gmail.com>
  16.  */
  17. class UserNotFoundException extends AuthenticationException
  18. {
  19.     private $identifier;
  20.     /**
  21.      * {@inheritdoc}
  22.      */
  23.     public function getMessageKey()
  24.     {
  25.         return 'Username could not be found.';
  26.     }
  27.     /**
  28.      * Get the user identifier (e.g. username or email address).
  29.      */
  30.     public function getUserIdentifier(): ?string
  31.     {
  32.         return $this->identifier;
  33.     }
  34.     /**
  35.      * @return string
  36.      *
  37.      * @deprecated
  38.      */
  39.     public function getUsername()
  40.     {
  41.         trigger_deprecation('symfony/security-core''5.3''Method "%s()" is deprecated, use getUserIdentifier() instead.'__METHOD__);
  42.         return $this->identifier;
  43.     }
  44.     /**
  45.      * Set the user identifier (e.g. username or email address).
  46.      */
  47.     public function setUserIdentifier(string $identifier): void
  48.     {
  49.         $this->identifier $identifier;
  50.     }
  51.     /**
  52.      * @deprecated
  53.      */
  54.     public function setUsername(string $username)
  55.     {
  56.         trigger_deprecation('symfony/security-core''5.3''Method "%s()" is deprecated, use setUserIdentifier() instead.'__METHOD__);
  57.         $this->identifier $username;
  58.     }
  59.     /**
  60.      * {@inheritdoc}
  61.      */
  62.     public function getMessageData()
  63.     {
  64.         return ['{{ username }}' => $this->identifier'{{ user_identifier }}' => $this->identifier];
  65.     }
  66.     /**
  67.      * {@inheritdoc}
  68.      */
  69.     public function __serialize(): array
  70.     {
  71.         return [$this->identifierparent::__serialize()];
  72.     }
  73.     /**
  74.      * {@inheritdoc}
  75.      */
  76.     public function __unserialize(array $data): void
  77.     {
  78.         [$this->identifier$parentData] = $data;
  79.         $parentData \is_array($parentData) ? $parentData unserialize($parentData);
  80.         parent::__unserialize($parentData);
  81.     }
  82. }
  83. if (!class_exists(UsernameNotFoundException::class, false)) {
  84.     class_alias(UserNotFoundException::class, UsernameNotFoundException::class);
  85. }