MissingUserProvider.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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\User;
  11. use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
  12. /**
  13. * MissingUserProvider is a dummy user provider used to throw proper exception
  14. * when a firewall requires a user provider but none was defined.
  15. *
  16. * @internal
  17. */
  18. class MissingUserProvider implements UserProviderInterface
  19. {
  20. /**
  21. * @param string $firewall the firewall missing a provider
  22. */
  23. public function __construct(string $firewall)
  24. {
  25. throw new InvalidConfigurationException(sprintf('"%s" firewall requires a user provider but none was defined.', $firewall));
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function loadUserByUsername(string $username): UserInterface
  31. {
  32. throw new \BadMethodCallException();
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function refreshUser(UserInterface $user): UserInterface
  38. {
  39. throw new \BadMethodCallException();
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function supportsClass(string $class): bool
  45. {
  46. throw new \BadMethodCallException();
  47. }
  48. }