class ImportNode
Represents an import node.
@author Fabien Potencier <fabien@symfony.com>
Hierarchy
- class \Twig\Node\Node implements \Twig\Node\Countable, \Twig\Node\IteratorAggregate
- class \Twig\Node\ImportNode extends \Twig\Node\Node
Expanded class hierarchy of ImportNode
3 files declare their use of ImportNode
- EscaperNodeVisitor.php in vendor/
twig/ twig/ src/ NodeVisitor/ EscaperNodeVisitor.php - FromTokenParser.php in vendor/
twig/ twig/ src/ TokenParser/ FromTokenParser.php - ImportTokenParser.php in vendor/
twig/ twig/ src/ TokenParser/ ImportTokenParser.php
File
-
vendor/
twig/ twig/ src/ Node/ ImportNode.php, line 25
Namespace
Twig\NodeView source
class ImportNode extends Node {
public function __construct(AbstractExpression $expr, AbstractExpression|AssignTemplateVariable $var, int $lineno) {
if (\func_num_args() > 3) {
trigger_deprecation('twig/twig', '3.15', \sprintf('Passing more than 3 arguments to "%s()" is deprecated.', __METHOD__));
}
if (!$var instanceof AssignTemplateVariable) {
trigger_deprecation('twig/twig', '3.15', \sprintf('Passing a "%s" instance as the second argument of "%s" is deprecated, pass a "%s" instead.', $var::class, __CLASS__, AssignTemplateVariable::class));
$var = new AssignTemplateVariable($var->getAttribute('name'), $lineno);
}
parent::__construct([
'expr' => $expr,
'var' => $var,
], [], $lineno);
}
public function compile(Compiler $compiler) : void {
$compiler->subcompile($this->getNode('var'));
if ($this->getNode('expr') instanceof NameExpression && '_self' === $this->getNode('expr')
->getAttribute('name')) {
$compiler->raw('$this');
}
else {
$compiler->raw('$this->loadTemplate(')
->subcompile($this->getNode('expr'))
->raw(', ')
->repr($this->getTemplateName())
->raw(', ')
->repr($this->getTemplateLine())
->raw(')->unwrap()');
}
$compiler->raw(";\n");
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
ImportNode::compile | public | function | Overrides Node::compile | ||
ImportNode::__construct | public | function | Overrides Node::__construct | ||
Node::$attributeNameDeprecations | private | property | @var array<string, NameDeprecation> | ||
Node::$attributes | protected | property | |||
Node::$lineno | protected | property | |||
Node::$nodeNameDeprecations | private | property | @var array<string, NameDeprecation> | ||
Node::$nodes | protected | property | |||
Node::$sourceContext | private | property | |||
Node::$tag | protected | property | |||
Node::count | public | function | |||
Node::deprecateAttribute | public | function | |||
Node::deprecateNode | public | function | |||
Node::getAttribute | public | function | |||
Node::getIterator | public | function | |||
Node::getNode | public | function | |||
Node::getNodeTag | public | function | |||
Node::getSourceContext | public | function | |||
Node::getTemplateLine | public | function | |||
Node::getTemplateName | public | function | |||
Node::hasAttribute | public | function | |||
Node::hasNode | public | function | |||
Node::removeAttribute | public | function | |||
Node::removeNode | public | function | |||
Node::setAttribute | public | function | |||
Node::setNode | public | function | 1 | ||
Node::setNodeTag | public | function | @internal | ||
Node::setSourceContext | public | function | |||
Node::__toString | public | function |