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

Embeds a template. More...

+ Inheritance diagram for Twig_TokenParser_Embed:
+ Collaboration diagram for Twig_TokenParser_Embed:

Public Member Functions

 parse (Twig_Token $token)
 Parses a token and returns a node. More...
 
 decideBlockEnd (Twig_Token $token)
 
 getTag ()
 Gets the tag name associated with this token parser. More...
 
 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...
 
 setParser (Twig_Parser $parser)
 Sets the parser associated with this token parser. More...
 
 parse (Twig_Token $token)
 Parses a token and returns a node. More...
 
 getTag ()
 Gets the tag name associated with this token parser. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Twig_TokenParser_Include
 parseArguments ()
 
- Protected Attributes inherited from Twig_TokenParser
 $parser
 

Detailed Description

Embeds a template.

@final

Definition at line 17 of file Embed.php.

Member Function Documentation

◆ decideBlockEnd()

Twig_TokenParser_Embed::decideBlockEnd ( Twig_Token  $token)

Definition at line 56 of file Embed.php.

57 {
58 return $token->test('endembed');
59 }

References PHPMailer\PHPMailer\$token.

◆ getTag()

Twig_TokenParser_Embed::getTag ( )

Gets the tag name associated with this token parser.

Returns
string The tag name

Reimplemented from Twig_TokenParser_Include.

Definition at line 61 of file Embed.php.

62 {
63 return 'embed';
64 }

◆ parse()

Twig_TokenParser_Embed::parse ( Twig_Token  $token)

Parses a token and returns a node.

Returns
Twig_NodeInterface
Exceptions
Twig_Error_Syntax

Reimplemented from Twig_TokenParser_Include.

Definition at line 19 of file Embed.php.

20 {
21 $stream = $this->parser->getStream();
22
23 $parent = $this->parser->getExpressionParser()->parseExpression();
24
25 list($variables, $only, $ignoreMissing) = $this->parseArguments();
26
27 $parentToken = $fakeParentToken = new Twig_Token(Twig_Token::STRING_TYPE, '__parent__', $token->getLine());
28 if ($parent instanceof Twig_Node_Expression_Constant) {
29 $parentToken = new Twig_Token(Twig_Token::STRING_TYPE, $parent->getAttribute('value'), $token->getLine());
30 } elseif ($parent instanceof Twig_Node_Expression_Name) {
31 $parentToken = new Twig_Token(Twig_Token::NAME_TYPE, $parent->getAttribute('name'), $token->getLine());
32 }
33
34 // inject a fake parent to make the parent() function work
35 $stream->injectTokens(array(
37 new Twig_Token(Twig_Token::NAME_TYPE, 'extends', $token->getLine()),
38 $parentToken,
39 new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', $token->getLine()),
40 ));
41
42 $module = $this->parser->parse($stream, array($this, 'decideBlockEnd'), true);
43
44 // override the parent with the correct one
45 if ($fakeParentToken === $parentToken) {
46 $module->setNode('parent', $parent);
47 }
48
49 $this->parser->embedTemplate($module);
50
52
53 return new Twig_Node_Embed($module->getTemplateName(), $module->getAttribute('index'), $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag());
54 }
Represents an embed node.
Definition: Embed.php:18
Represents a Token.
Definition: Token.php:21
const BLOCK_END_TYPE
Definition: Token.php:30
const BLOCK_START_TYPE
Definition: Token.php:28
const NAME_TYPE
Definition: Token.php:32
const STRING_TYPE
Definition: Token.php:34
if($modEnd===false) $module
Definition: module.php:59
$stream
PHP stream implementation.

References $module, GuzzleHttp\Psr7\$stream, PHPMailer\PHPMailer\$token, Twig_Token\BLOCK_END_TYPE, Twig_Token\BLOCK_START_TYPE, Twig_Token\NAME_TYPE, Twig_TokenParser_Include\parseArguments(), and Twig_Token\STRING_TYPE.

+ Here is the call graph for this function:

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