ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Twig_TokenParser_Extends Class Reference

Extends a template by another one. More...

+ Inheritance diagram for Twig_TokenParser_Extends:
+ Collaboration diagram for Twig_TokenParser_Extends:

Public Member Functions

 parse (Twig_Token $token)
 Parses a token and returns a node. More...
 
 getTag ()
 Gets the tag name associated with this token parser. More...
 
- Public Member Functions inherited from Twig_TokenParser
 setParser (Twig_Parser $parser)
 Sets the parser associated with this token parser. More...
 

Additional Inherited Members

- Protected Attributes inherited from Twig_TokenParser
 $parser
 

Detailed Description

Extends a template by another one.

 {% extends "base.html" %}

Definition at line 22 of file Extends.php.

Member Function Documentation

◆ getTag()

Twig_TokenParser_Extends::getTag ( )

Gets the tag name associated with this token parser.

Returns
string The tag name

Implements Twig_TokenParserInterface.

Definition at line 40 of file Extends.php.

41  {
42  return 'extends';
43  }

◆ parse()

Twig_TokenParser_Extends::parse ( Twig_Token  $token)

Parses a token and returns a node.

Returns
Twig_NodeInterface
Exceptions
Twig_Error_Syntax

Implements Twig_TokenParserInterface.

Definition at line 24 of file Extends.php.

References GuzzleHttp\Psr7\$stream, Twig_Token\BLOCK_END_TYPE, and Twig_Token\getLine().

25  {
26  $stream = $this->parser->getStream();
27 
28  if (!$this->parser->isMainScope()) {
29  throw new Twig_Error_Syntax('Cannot extend from a block.', $token->getLine(), $stream->getSourceContext());
30  }
31 
32  if (null !== $this->parser->getParent()) {
33  throw new Twig_Error_Syntax('Multiple extends tags are forbidden.', $token->getLine(), $stream->getSourceContext());
34  }
35  $this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
36 
38  }
$stream
PHP stream implementation.
Exception thrown when a syntax error occurs during lexing or parsing of a template.
Definition: Syntax.php:18
getLine()
Definition: Token.php:87
const BLOCK_END_TYPE
Definition: Token.php:30
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: