ZF-2464: Add return values to Zend_Controller_Router_* for method chaining

Issue Type: Improvement Created: 2008-01-21T23:26:57.000+0000 Last Updated: 2008-01-29T11:48:40.000+0000 Status: Resolved Fix version(s): Reporter: David Rogers (al_the_x) Assignee: Michal Minicki (martel) Tags: - Zend_Controller

Related issues: - ZF-1893



The current implementation of Zend_Controller_Router objects does not specify a return value for many of the single-use methods, ie:

<pre class="highlight">
    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:

<pre class="highlight">
    ->addRoute('newRoute', new Zend_Controller_Router_Route(':module/:controller/:action'))
    ->addRoute('newRoute', new Zend_Controller_Router_Route(':controller/:action'))

This currently throws a fatal error: Call to method "addRoute()" on a non-object.


Posted by Michal Minicki (martel) on 2008-01-29T08:15:47.000+0000

RewrteRouter already allows method chaining:…

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?

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.