renamed Template::getParentBlock() and getBlock() to diplayParentBlock() and displayBlock(), which is semantically more correct

This commit is contained in:
Fabien Potencier
2010-12-30 09:30:10 +01:00
parent 522f35ed6b
commit d9e2c42e41
5 changed files with 11 additions and 13 deletions
+1 -1
View File
@@ -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')))
;
}
}
+1 -1
View File
@@ -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")
;
+7 -9
View File
@@ -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));
}
}
+1 -1
View File
@@ -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);'),
);
}
}
+1 -1
View File
@@ -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;
}