From d5721f10fdada2a17dbeea60e4e9cb57d8a94df6 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 d26ba64f3..d9a54baf0 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 e3a0795bede792f57fe266ba6fa4ce5dfab045df 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 d9a54baf0..b93594f56 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 */