mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 19:06:40 +00:00
changed the way we store node filenames
This commit is contained in:
+1
-13
@@ -85,7 +85,7 @@ class Twig_Compiler implements Twig_CompilerInterface
|
||||
$this->indentation = $indentation;
|
||||
|
||||
if ($node instanceof Twig_Node_Module) {
|
||||
$this->addFilenameAttribute($node, $node->getAttribute('filename'));
|
||||
$node->setFilename($node->getAttribute('filename'));
|
||||
|
||||
// to be removed in 2.0
|
||||
$this->filename = $node->getAttribute('filename');
|
||||
@@ -282,16 +282,4 @@ class Twig_Compiler implements Twig_CompilerInterface
|
||||
{
|
||||
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
|
||||
}
|
||||
|
||||
private function addFilenameAttribute(Twig_Node $node, $filename)
|
||||
{
|
||||
$node->setAttribute('module_filename', $filename);
|
||||
foreach ($node as $n) {
|
||||
if (null !== $n) {
|
||||
$this->addFilenameAttribute($n, $filename);
|
||||
}
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
|
||||
+13
-3
@@ -22,6 +22,8 @@ class Twig_Node implements Twig_NodeInterface
|
||||
protected $lineno;
|
||||
protected $tag;
|
||||
|
||||
private $filename;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -229,10 +231,18 @@ class Twig_Node implements Twig_NodeInterface
|
||||
return new ArrayIterator($this->nodes);
|
||||
}
|
||||
|
||||
public function getFilename()
|
||||
public function setFilename($filename)
|
||||
{
|
||||
if ($this->hasAttribute('module_filename')) {
|
||||
return $this->getAttribute('module_filename');
|
||||
$this->filename = $filename;
|
||||
foreach ($this->nodes as $node) {
|
||||
if (null !== $node) {
|
||||
$node->setFilename($filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getFilename()
|
||||
{
|
||||
return $this->filename;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user