CsrfRuntime.php 818 B

123456789101112131415161718192021222324252627282930313233
  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\Bridge\Twig\Extension;
  11. use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
  12. /**
  13. * @author Christian Flothmann <christian.flothmann@sensiolabs.de>
  14. * @author Titouan Galopin <galopintitouan@gmail.com>
  15. */
  16. final class CsrfRuntime
  17. {
  18. private $csrfTokenManager;
  19. public function __construct(CsrfTokenManagerInterface $csrfTokenManager)
  20. {
  21. $this->csrfTokenManager = $csrfTokenManager;
  22. }
  23. public function getCsrfToken(string $tokenId): string
  24. {
  25. return $this->csrfTokenManager->getToken($tokenId)->getValue();
  26. }
  27. }