From ea785efb30ced6ab399b290df6f202cb97315f80 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 25 Jun 2013 14:22:40 -0500 Subject: [feature/twig] PHP token support PHPBB3-11598 --- phpBB/includes/template/twig/tokenparser/php.php | 46 ++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 phpBB/includes/template/twig/tokenparser/php.php (limited to 'phpBB/includes/template/twig/tokenparser/php.php') 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 @@ +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'; + } +} -- cgit v1.2.1 From 57c2d99e65ce107208db10721cff5b815ee3403c Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 12:34:16 -0500 Subject: [feature/twig] Fix indentation PHPBB3-11598 --- phpBB/includes/template/twig/tokenparser/php.php | 52 ++++++++++++------------ 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'phpBB/includes/template/twig/tokenparser/php.php') diff --git a/phpBB/includes/template/twig/tokenparser/php.php b/phpBB/includes/template/twig/tokenparser/php.php index 7db57081e2..62e1c4fdcd 100644 --- a/phpBB/includes/template/twig/tokenparser/php.php +++ b/phpBB/includes/template/twig/tokenparser/php.php @@ -9,38 +9,38 @@ 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(); + /** + * 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); + $stream->expect(Twig_Token::BLOCK_END_TYPE); $body = $this->parser->subparse(array($this, 'decideEnd'), true); - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); - return new phpbb_template_twig_node_php($body, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); - } + 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'); - } + 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'; + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'PHP'; } } -- cgit v1.2.1 From c5c34ff831faf96368d34012dc65bdb9451227aa Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 13:10:35 -0500 Subject: [feature/twig] Add check for defined IN_PHPBB in all new Twig related files PHPBB3-11598 --- phpBB/includes/template/twig/tokenparser/php.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/includes/template/twig/tokenparser/php.php') diff --git a/phpBB/includes/template/twig/tokenparser/php.php b/phpBB/includes/template/twig/tokenparser/php.php index 62e1c4fdcd..197980a59a 100644 --- a/phpBB/includes/template/twig/tokenparser/php.php +++ b/phpBB/includes/template/twig/tokenparser/php.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_tokenparser_php extends Twig_TokenParser { /** -- cgit v1.2.1