ZF-2464: Add return values to Zend_Controller_Router_* for method chaining
Description
The current implementation of Zend_Controller_Router objects does not specify a return value for many of the single-use methods, ie:
public function addRoutes($routes) {
foreach ($routes as $name => $route) {
$this->addRoute($name, $route);
}
}
For the sake of method chaining, these functions should return the object ( return $this; ), permitting calls like the following:
Zend_Controller_Front::getInstance()->getRouter()
->addRoute('newRoute', new Zend_Controller_Router_Route(':module/:controller/:action'))
->addRoute('newRoute', new Zend_Controller_Router_Route(':controller/:action'))
->dispatch();
This currently throws a fatal error: Call to method "addRoute()" on a non-object.
Comments
Posted by Michal Minicki (martel) on 2008-01-29T08:15:47.000+0000
RewrteRouter already allows method chaining:
http://framework.zend.com/svn/framework/…
Posted by David Rogers (al_the_x) on 2008-01-29T08:44:58.000+0000
Not to nit-pick, but addDefaultRoutes() still doesn't...
Posted by Michal Minicki (martel) on 2008-01-29T08:55:47.000+0000
David, do you actually use this method? It's an internal method which generally should be protected.
Posted by David Rogers (al_the_x) on 2008-01-29T11:48:40.000+0000
Actually, no... My overridden version of the class did to imitate the functionality of the parent, but no worries. Is this fixed in a release version?