ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 
- Public Member Functions inherited from Twig_TokenParser_Include
 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 Member Functions inherited from Twig_TokenParser_Include
 parseArguments ()
 
- Protected Attributes inherited from Twig_TokenParser
 $parser
 

Detailed Description

Embeds a template.

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.

References Twig_Token\test().

57  {
58  return $token->test('endembed');
59  }
test($type, $values=null)
Tests the current token for a type and/or a value.
Definition: Token.php:70
+ Here is the call graph for this function:

◆ getTag()

Twig_TokenParser_Embed::getTag ( )

Gets the tag name associated with this token parser.

Returns
string The tag name

Implements Twig_TokenParserInterface.

Definition at line 61 of file Embed.php.

Referenced by parse().

62  {
63  return 'embed';
64  }
+ Here is the caller graph for this function:

◆ parse()

Twig_TokenParser_Embed::parse ( Twig_Token  $token)

Parses a token and returns a node.

Returns
Twig_NodeInterface
Exceptions
Twig_Error_Syntax

Implements Twig_TokenParserInterface.

Definition at line 19 of file Embed.php.

References $module, GuzzleHttp\Psr7\$stream, array, Twig_Token\BLOCK_END_TYPE, Twig_Token\BLOCK_START_TYPE, Twig_Token\getLine(), getTag(), Twig_Token\NAME_TYPE, Twig_TokenParser_Include\parseArguments(), and Twig_Token\STRING_TYPE.

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  }
getTag()
Gets the tag name associated with this token parser.
Definition: Embed.php:61
$stream
PHP stream implementation.
if($modEnd===false) $module
Definition: module.php:59
const STRING_TYPE
Definition: Token.php:34
const BLOCK_START_TYPE
Definition: Token.php:28
Create styles array
The data for the language used.
Represents an embed node.
Definition: Embed.php:17
getLine()
Definition: Token.php:87
const NAME_TYPE
Definition: Token.php:32
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: