From: Fabien Potencier Date: Thu, 30 Dec 2010 08:30:10 +0000 (+0100) Subject: renamed Template::getParentBlock() and getBlock() to diplayParentBlock() and displayB... X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=d9e2c42e412fad137ccfb9fe372304f77f2528e4;p=web%2Fkonrad%2Ftwig.git renamed Template::getParentBlock() and getBlock() to diplayParentBlock() and displayBlock(), which is semantically more correct --- diff --git a/lib/Twig/Node/BlockReference.php b/lib/Twig/Node/BlockReference.php index 4fd5ece..e195c7f 100644 --- a/lib/Twig/Node/BlockReference.php +++ b/lib/Twig/Node/BlockReference.php @@ -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'))) ; } } diff --git a/lib/Twig/Node/Parent.php b/lib/Twig/Node/Parent.php index db3e708..b2498fa 100644 --- a/lib/Twig/Node/Parent.php +++ b/lib/Twig/Node/Parent.php @@ -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") ; diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index 0a38087..e8f5be0 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -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)); } } diff --git a/test/Twig/Tests/Node/BlockReferenceTest.php b/test/Twig/Tests/Node/BlockReferenceTest.php index f77f7f0..f1c5ab1 100644 --- a/test/Twig/Tests/Node/BlockReferenceTest.php +++ b/test/Twig/Tests/Node/BlockReferenceTest.php @@ -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);'), ); } } diff --git a/test/Twig/Tests/Node/ParentTest.php b/test/Twig/Tests/Node/ParentTest.php index f239ef4..607b4f1 100644 --- a/test/Twig/Tests/Node/ParentTest.php +++ b/test/Twig/Tests/Node/ParentTest.php @@ -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; }