TransDefaultDomainTokenParser.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. class TransDefaultDomainTokenParser extends AbstractTokenParser
  21. {
  22. /**
  23. * Parses a token and returns a node.
  24. *
  25. * @param Token $token
  26. *
  27. * @return Node
  28. */
  29. public function parse(Token $token)
  30. {
  31. $expr = $this->parser->getExpressionParser()->parseExpression();
  32. $this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
  33. return new TransDefaultDomainNode($expr, $token->getLine(), $this->getTag());
  34. }
  35. /**
  36. * Gets the tag name associated with this token parser.
  37. *
  38. * @return string The tag name
  39. */
  40. public function getTag()
  41. {
  42. return 'trans_default_domain';
  43. }
  44. }