From 8a8d2697d1461cac01c146f1f68dc239d464440f Mon Sep 17 00:00:00 2001 From: Mark Oberemk Date: Tue, 11 Mar 2014 10:37:47 -0400 Subject: [PATCH 1/2] Allow chaining in the addCrumb method For convenience I think it might be valuable to allow addCrumb (and possibly other similar functions) to return $this to permit chained calls such as this: $this->Html->addCrumb('Admin', '/admin')->addCrumb('Blogs', '/admin/users')->addCrumb('Add'); as opposed to the considerably more verbose version that needs to be used now: $this->Html->addCrumb('Admin', '/admin'); $this->Html->addCrumb('Blogs', '/admin/users'); $this->Html->addCrumb('Add'); I'm not sure if this violates some API conventions for helpers but it does seem rather more convenient to work with to me. --- lib/Cake/View/Helper/HtmlHelper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 6ce3cfafa..454514dc1 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -180,6 +180,7 @@ class HtmlHelper extends AppHelper { */ public function addCrumb($name, $link = null, $options = null) { $this->_crumbs[] = array($name, $link, $options); + return $this; } /** From 3f7eff18436c7900c563362d9218cf1351422c68 Mon Sep 17 00:00:00 2001 From: Mark Oberemk Date: Wed, 12 Mar 2014 08:59:12 -0400 Subject: [PATCH 2/2] Update HtmlHelper.php Updated documentation to include the chained $this return --- lib/Cake/View/Helper/HtmlHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 454514dc1..edbf8e219 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -174,7 +174,7 @@ class HtmlHelper extends AppHelper { * @param string $name Text for link * @param string $link URL for link (if empty it won't be a link) * @param string|array $options Link attributes e.g. array('id' => 'selected') - * @return void + * @return this HtmlHelper * @see HtmlHelper::link() for details on $options that can be used. * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#creating-breadcrumb-trails-with-htmlhelper */