diff options
author | Nathaniel Guse <nathaniel.guse@gmail.com> | 2013-06-25 14:22:40 -0500 |
---|---|---|
committer | Nathaniel Guse <nathaniel.guse@gmail.com> | 2013-06-25 14:22:40 -0500 |
commit | ea785efb30ced6ab399b290df6f202cb97315f80 (patch) | |
tree | 22d2a9e21be4cb46aa0750336aef444926e28eff /phpBB/includes/template/twig/tokenparser | |
parent | fe61527c5245d3d627e51c96b7b482c526b7dd28 (diff) | |
download | forums-ea785efb30ced6ab399b290df6f202cb97315f80.tar forums-ea785efb30ced6ab399b290df6f202cb97315f80.tar.gz forums-ea785efb30ced6ab399b290df6f202cb97315f80.tar.bz2 forums-ea785efb30ced6ab399b290df6f202cb97315f80.tar.xz forums-ea785efb30ced6ab399b290df6f202cb97315f80.zip |
[feature/twig] PHP token support
PHPBB3-11598
Diffstat (limited to 'phpBB/includes/template/twig/tokenparser')
-rw-r--r-- | phpBB/includes/template/twig/tokenparser/php.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/phpBB/includes/template/twig/tokenparser/php.php b/phpBB/includes/template/twig/tokenparser/php.php new file mode 100644 index 0000000000..7db57081e2 --- /dev/null +++ b/phpBB/includes/template/twig/tokenparser/php.php @@ -0,0 +1,46 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +class phpbb_template_twig_tokenparser_php extends Twig_TokenParser +{ + /** + * Parses a token and returns a node. + * + * @param Twig_Token $token A Twig_Token instance + * + * @return Twig_NodeInterface A Twig_NodeInterface instance + */ + public function parse(Twig_Token $token) + { + $stream = $this->parser->getStream(); + + $stream->expect(Twig_Token::BLOCK_END_TYPE); + + $body = $this->parser->subparse(array($this, 'decideEnd'), true); + + $stream->expect(Twig_Token::BLOCK_END_TYPE); + + return new phpbb_template_twig_node_php($body, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); + } + + public function decideEnd(Twig_Token $token) + { + return $token->test('ENDPHP'); + } + + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'PHP'; + } +} |