mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 10:56:38 +00:00
renamed Template::getParentBlock() and getBlock() to diplayParentBlock() and displayBlock(), which is semantically more correct
This commit is contained in:
@@ -32,7 +32,7 @@ class Twig_Node_BlockReference extends Twig_Node
|
||||
{
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
->write(sprintf("\$this->getBlock('%s', \$context, \$blocks);\n", $this->getAttribute('name')))
|
||||
->write(sprintf("\$this->displayBlock('%s', \$context, \$blocks);\n", $this->getAttribute('name')))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class Twig_Node_Parent extends Twig_Node
|
||||
{
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
->write("\$this->getParentBlock(")
|
||||
->write("\$this->displayParentBlock(")
|
||||
->string($this->getAttribute('name'))
|
||||
->raw(", \$context, \$blocks);\n")
|
||||
;
|
||||
|
||||
@@ -37,27 +37,25 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getParentBlock($name, array $context, array $blocks = array())
|
||||
public function displayParentBlock($name, array $context, array $blocks = array())
|
||||
{
|
||||
if (false !== $parent = $this->getParent($context)) {
|
||||
return $parent->getBlock($name, $context, $blocks);
|
||||
$parent->displayBlock($name, $context, $blocks);
|
||||
} else {
|
||||
throw new Twig_Error_Runtime('This template has no parent', -1, $this->getTemplateName());
|
||||
}
|
||||
}
|
||||
|
||||
public function getBlock($name, array $context, array $blocks = array())
|
||||
public function displayBlock($name, array $context, array $blocks = array())
|
||||
{
|
||||
if (isset($blocks[$name])) {
|
||||
$b = $blocks;
|
||||
unset($b[$name]);
|
||||
return call_user_func($blocks[$name], $context, $b);
|
||||
call_user_func($blocks[$name], $context, $b);
|
||||
} elseif (isset($this->blocks[$name])) {
|
||||
return call_user_func($this->blocks[$name], $context, $blocks);
|
||||
}
|
||||
|
||||
if (false !== $parent = $this->getParent($context)) {
|
||||
return $parent->getBlock($name, $context, array_merge($this->blocks, $blocks));
|
||||
call_user_func($this->blocks[$name], $context, $blocks);
|
||||
} elseif (false !== $parent = $this->getParent($context)) {
|
||||
$parent->displayBlock($name, $context, array_merge($this->blocks, $blocks));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class Twig_Tests_Node_BlockReferenceTest extends Twig_Tests_Node_TestCase
|
||||
public function getTests()
|
||||
{
|
||||
return array(
|
||||
array(new Twig_Node_BlockReference('foo', 0), '$this->getBlock(\'foo\', $context, $blocks);'),
|
||||
array(new Twig_Node_BlockReference('foo', 0), '$this->displayBlock(\'foo\', $context, $blocks);'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class Twig_Tests_Node_ParentTest extends Twig_Tests_Node_TestCase
|
||||
public function getTests()
|
||||
{
|
||||
$tests = array();
|
||||
$tests[] = array(new Twig_Node_Parent('foo', 0), '$this->getParentBlock("foo", $context, $blocks);');
|
||||
$tests[] = array(new Twig_Node_Parent('foo', 0), '$this->displayParentBlock("foo", $context, $blocks);');
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user