mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-17 12:57:05 +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;
|
$this->indentation = $indentation;
|
||||||
|
|
||||||
if ($node instanceof Twig_Node_Module) {
|
if ($node instanceof Twig_Node_Module) {
|
||||||
$this->addFilenameAttribute($node, $node->getAttribute('filename'));
|
$node->setFilename($node->getAttribute('filename'));
|
||||||
|
|
||||||
// to be removed in 2.0
|
// to be removed in 2.0
|
||||||
$this->filename = $node->getAttribute('filename');
|
$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));
|
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 $lineno;
|
||||||
protected $tag;
|
protected $tag;
|
||||||
|
|
||||||
|
private $filename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
@@ -229,10 +231,18 @@ class Twig_Node implements Twig_NodeInterface
|
|||||||
return new ArrayIterator($this->nodes);
|
return new ArrayIterator($this->nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFilename()
|
public function setFilename($filename)
|
||||||
{
|
{
|
||||||
if ($this->hasAttribute('module_filename')) {
|
$this->filename = $filename;
|
||||||
return $this->getAttribute('module_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