4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Bridge\Twig\TokenParser
;
14 use Symfony\Bridge\Twig\Node\FormThemeNode
;
17 * Token Parser for the 'form_theme' tag.
19 * @author Fabien Potencier <fabien@symfony.com>
21 class FormThemeTokenParser
extends \Twig_TokenParser
24 * Parses a token and returns a node.
26 * @param \Twig_Token $token A Twig_Token instance
28 * @return \Twig_NodeInterface A Twig_NodeInterface instance
30 public function parse(\Twig_Token
$token)
32 $lineno = $token->getLine();
33 $stream = $this->parser
->getStream();
35 $form = $this->parser
->getExpressionParser()->parseExpression();
37 if ($this->parser
->getStream()->test(\Twig_Token
::NAME_TYPE
, 'with')) {
38 $this->parser
->getStream()->next();
39 $resources = $this->parser
->getExpressionParser()->parseExpression();
41 $resources = new \
Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
43 $resources->addElement($this->parser
->getExpressionParser()->parseExpression());
44 } while (!$stream->test(\Twig_Token
::BLOCK_END_TYPE
));
47 $stream->expect(\Twig_Token
::BLOCK_END_TYPE
);
49 return new FormThemeNode($form, $resources, $lineno, $this->getTag());
53 * Gets the tag name associated with this token parser.
55 * @return string The tag name
57 public function getTag()