Skip to content
Permalink
Browse files

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.
  • Loading branch information...
moberemk committed Mar 11, 2014
1 parent c0ac611 commit 8a8d2697d1461cac01c146f1f68dc239d464440f
Showing with 1 addition and 0 deletions.
  1. +1 −0 lib/Cake/View/Helper/HtmlHelper.php
@@ -180,6 +180,7 @@ public function __construct(View $View, $settings = array()) {
*/
public function addCrumb($name, $link = null, $options = null) {
$this->_crumbs[] = array($name, $link, $options);
return $this;
}
/**

1 comment on commit 8a8d269

@davidyell

This comment has been minimized.

Copy link
Contributor

davidyell commented on 8a8d269 Apr 16, 2014

Simple change for so much value 👍

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.