Skip to content

Commit

Permalink
bug #4050 synchronize sourceContext (Lumaraf)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

synchronize sourceContext

I have some debugging extensions that need the template name from various nodes in a `NodeVisitor`. Currently this is guaranteed for the nodes created from parsing the template. This ensures that the `SourceContext` is also set for nodes created by `NodeVisitors` modifying the node tree.

I am not sure if it is a good idea to always set the `SourceContext` on a child node or if this should only set it if it is not set.

Commits
-------

350670a synchronize sourceContext
  • Loading branch information
fabpot committed Apr 27, 2024
2 parents 4a7de4a + 350670a commit 57a9cdb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Node/Node.php
Expand Up @@ -138,6 +138,9 @@ public function getNode(string $name): self

public function setNode(string $name, self $node): void
{
if (null !== $this->sourceContext) {
$node->setSourceContext($this->sourceContext);
}
$this->nodes[$name] = $node;
}

Expand Down

0 comments on commit 57a9cdb

Please sign in to comment.