PEEL Shopping
Open source ecommerce : PEEL Shopping
Sandbox.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of Twig.
5  *
6  * (c) 2010 Fabien Potencier
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
24 {
32  public function parse(Twig_Token $token)
33  {
34  $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
35  $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
36  $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
37 
38  // in a sandbox tag, only include tags are allowed
39  if (!$body instanceof Twig_Node_Include) {
40  foreach ($body as $node) {
41  if ($node instanceof Twig_Node_Text && ctype_space($node->getAttribute('data'))) {
42  continue;
43  }
44 
45  if (!$node instanceof Twig_Node_Include) {
46  throw new Twig_Error_Syntax('Only "include" tags are allowed within a "sandbox" section', $node->getLine(), $this->parser->getFilename());
47  }
48  }
49  }
50 
51  return new Twig_Node_Sandbox($body, $token->getLine(), $this->getTag());
52  }
53 
54  public function decideBlockEnd(Twig_Token $token)
55  {
56  return $token->test('endsandbox');
57  }
58 
64  public function getTag()
65  {
66  return 'sandbox';
67  }
68 }
decideBlockEnd(Twig_Token $token)
Definition: Sandbox.php:54
Base class for all token parsers.
Definition: TokenParser.php:17
Marks a section of a template as untrusted code that must be evaluated in the sandbox mode...
Definition: Sandbox.php:23
getTag()
Gets the tag name associated with this token parser.
Definition: Sandbox.php:64
parse(Twig_Token $token)
Parses a token and returns a node.
Definition: Sandbox.php:32
Represents an include node.
Definition: Include.php:18
Exception thrown when a syntax error occurs during lexing or parsing of a template.
Definition: Syntax.php:18
Represents a sandbox node.
Definition: Sandbox.php:17
const BLOCK_END_TYPE
Definition: Token.php:28
Represents a Token.
Definition: Token.php:18
getLine()
Gets the line.
Definition: Token.php:94
test($type, $values=null)
Tests the current token for a type and/or a value.
Definition: Token.php:75
Represents a text node.
Definition: Text.php:18

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:18 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.