AbstractGuardAuthenticator.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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\Guard;
  11. use Symfony\Component\Security\Core\User\UserInterface;
  12. use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken;
  13. /**
  14. * An optional base class that creates a PostAuthenticationGuardToken for you.
  15. *
  16. * @author Ryan Weaver <ryan@knpuniversity.com>
  17. */
  18. abstract class AbstractGuardAuthenticator implements AuthenticatorInterface
  19. {
  20. /**
  21. * Shortcut to create a PostAuthenticationGuardToken for you, if you don't really
  22. * care about which authenticated token you're using.
  23. *
  24. * @return PostAuthenticationGuardToken
  25. */
  26. public function createAuthenticatedToken(UserInterface $user, string $providerKey)
  27. {
  28. return new PostAuthenticationGuardToken(
  29. $user,
  30. $providerKey,
  31. $user->getRoles()
  32. );
  33. }
  34. }