mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 19:06:40 +00:00
deprecated Twig_Compiler::getFilename()
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
* 1.24.3 (2016-XX-XX)
|
||||
* 1.25.0 (2016-XX-XX)
|
||||
|
||||
* n/a
|
||||
* deprecated Twig_Compiler::getFilename()
|
||||
|
||||
* 1.24.2 (2016-09-01)
|
||||
|
||||
|
||||
@@ -36,8 +36,13 @@ class Twig_Compiler implements Twig_CompilerInterface
|
||||
$this->env = $env;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.25 (to be removed in 2.0)
|
||||
*/
|
||||
public function getFilename()
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
|
||||
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
@@ -80,6 +85,9 @@ class Twig_Compiler implements Twig_CompilerInterface
|
||||
$this->indentation = $indentation;
|
||||
|
||||
if ($node instanceof Twig_Node_Module) {
|
||||
$this->addFilenameAttribute($node, $node->getAttribute('filename'));
|
||||
|
||||
// to be removed in 2.0
|
||||
$this->filename = $node->getAttribute('filename');
|
||||
}
|
||||
|
||||
@@ -274,4 +282,16 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,4 +228,11 @@ class Twig_Node implements Twig_NodeInterface
|
||||
{
|
||||
return new ArrayIterator($this->nodes);
|
||||
}
|
||||
|
||||
public function getFilename()
|
||||
{
|
||||
if ($this->hasAttribute('module_filename')) {
|
||||
return $this->getAttribute('module_filename');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class Twig_Node_Embed extends Twig_Node_Include
|
||||
->write('$this->loadTemplate(')
|
||||
->string($this->getAttribute('filename'))
|
||||
->raw(', ')
|
||||
->repr($compiler->getFilename())
|
||||
->repr($this->getFilename())
|
||||
->raw(', ')
|
||||
->repr($this->getLine())
|
||||
->raw(', ')
|
||||
|
||||
@@ -37,7 +37,7 @@ class Twig_Node_Import extends Twig_Node
|
||||
->raw('$this->loadTemplate(')
|
||||
->subcompile($this->getNode('expr'))
|
||||
->raw(', ')
|
||||
->repr($compiler->getFilename())
|
||||
->repr($this->getFilename())
|
||||
->raw(', ')
|
||||
->repr($this->getLine())
|
||||
->raw(')')
|
||||
|
||||
@@ -59,7 +59,7 @@ class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface
|
||||
->write('$this->loadTemplate(')
|
||||
->subcompile($this->getNode('expr'))
|
||||
->raw(', ')
|
||||
->repr($compiler->getFilename())
|
||||
->repr($this->getFilename())
|
||||
->raw(', ')
|
||||
->repr($this->getLine())
|
||||
->raw(')')
|
||||
|
||||
@@ -112,7 +112,7 @@ class Twig_Node_Module extends Twig_Node
|
||||
->raw('$this->loadTemplate(')
|
||||
->subcompile($parent)
|
||||
->raw(', ')
|
||||
->repr($compiler->getFilename())
|
||||
->repr($this->getAttribute('filename'))
|
||||
->raw(', ')
|
||||
->repr($this->getNode('parent')->getLine())
|
||||
->raw(')')
|
||||
@@ -157,7 +157,7 @@ class Twig_Node_Module extends Twig_Node
|
||||
->write('$this->parent = $this->loadTemplate(')
|
||||
->subcompile($parent)
|
||||
->raw(', ')
|
||||
->repr($compiler->getFilename())
|
||||
->repr($this->getAttribute('filename'))
|
||||
->raw(', ')
|
||||
->repr($this->getNode('parent')->getLine())
|
||||
->raw(");\n")
|
||||
@@ -391,7 +391,7 @@ class Twig_Node_Module extends Twig_Node
|
||||
->write(sprintf('%s = $this->loadTemplate(', $var))
|
||||
->subcompile($node)
|
||||
->raw(', ')
|
||||
->repr($compiler->getFilename())
|
||||
->repr($this->getAttribute('filename'))
|
||||
->raw(', ')
|
||||
->repr($node->getLine())
|
||||
->raw(");\n")
|
||||
|
||||
Reference in New Issue
Block a user