TransDefaultDomainTokenParser.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\TokenParser;
  11. use Symfony\Bridge\Twig\Node\TransDefaultDomainNode;
  12. use Twig\Node\Node;
  13. use Twig\Token;
  14. use Twig\TokenParser\AbstractTokenParser;
  15. /**
  16. * Token Parser for the 'trans_default_domain' tag.
  17. *
  18. * @author Fabien Potencier <fabien@symfony.com>
  19. */
  20. final class TransDefaultDomainTokenParser extends AbstractTokenParser
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function parse(Token $token): Node
  26. {
  27. $expr = $this->parser->getExpressionParser()->parseExpression();
  28. $this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
  29. return new TransDefaultDomainNode($expr, $token->getLine(), $this->getTag());
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function getTag(): string
  35. {
  36. return 'trans_default_domain';
  37. }
  38. }