TransDefaultDomainTokenParser.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. /**
  13. * Token Parser for the 'trans_default_domain' tag.
  14. *
  15. * @author Fabien Potencier <fabien@symfony.com>
  16. */
  17. class TransDefaultDomainTokenParser extends \Twig_TokenParser
  18. {
  19. /**
  20. * Parses a token and returns a node.
  21. *
  22. * @param \Twig_Token $token A Twig_Token instance
  23. *
  24. * @return \Twig_NodeInterface A Twig_NodeInterface instance
  25. */
  26. public function parse(\Twig_Token $token)
  27. {
  28. $expr = $this->parser->getExpressionParser()->parseExpression();
  29. $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
  30. return new TransDefaultDomainNode($expr, $token->getLine(), $this->getTag());
  31. }
  32. /**
  33. * Gets the tag name associated with this token parser.
  34. *
  35. * @return string The tag name
  36. */
  37. public function getTag()
  38. {
  39. return 'trans_default_domain';
  40. }
  41. }