vendor/symfony/security-http/Authenticator/Passport/Badge/RememberMeBadge.php line 27

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\Http\Authenticator\Passport\Badge;
  11. use Symfony\Component\Security\Http\EventListener\CheckRememberMeConditionsListener;
  12. /**
  13. * Adds support for remember me to this authenticator.
  14. *
  15. * The presence of this badge doesn't create the remember-me cookie. The actual
  16. * cookie is only created if this badge is enabled. By default, this is done
  17. * by the {@see CheckRememberMeConditionsListener} if all conditions are met.
  18. *
  19. * @author Wouter de Jong <wouter@wouterj.nl>
  20. *
  21. * @final
  22. */
  23. class RememberMeBadge implements BadgeInterface
  24. {
  25. private $enabled = false;
  26. /**
  27. * Enables remember-me cookie creation.
  28. *
  29. * In most cases, {@see CheckRememberMeConditionsListener} enables this
  30. * automatically if always_remember_me is true or the remember_me_parameter
  31. * exists in the request.
  32. *
  33. * @return $this
  34. */
  35. public function enable(): self
  36. {
  37. $this->enabled = true;
  38. return $this;
  39. }
  40. /**
  41. * Disables remember-me cookie creation.
  42. *
  43. * The default is disabled, this can be called to suppress creation
  44. * after it was enabled.
  45. *
  46. * @return $this
  47. */
  48. public function disable(): self
  49. {
  50. $this->enabled = false;
  51. return $this;
  52. }
  53. public function isEnabled(): bool
  54. {
  55. return $this->enabled;
  56. }
  57. public function isResolved(): bool
  58. {
  59. return true; // remember me does not need to be explicitly resolved
  60. }
  61. }