ZF-6398: Improve Zend_Controller_Router_Route_Chain that Routes added to Chains still could be used in Router without chains

Issue Type: Sub-task Created: 2009-04-23T11:50:11.000+0000 Last Updated: 2009-04-26T14:43:53.000+0000 Status: Resolved Fix version(s): - 1.8.0 (30/Apr/09)

Reporter: Anjey Lobas (anjey) Assignee: Ben Scholzen (dasprid) Tags: - Zend_Controller

Related issues: Attachments:


Currently (version 1.8) method chain of Zend_Controller_Router_Route_Chain looks like:

public function chain(Zend_Controller_Router_Route_Abstract $route, $separator = '/')

    $this->_routes[]     = $route;
    $this->_separators[] = $separator;

    return $this;


So when you add any Route object to chain it becomes Partial and stop function outside a chain.

Let say we need to reuse some route object in different chains to minimize memory usage. It's ok. But if we need to add this route to router without using chains (i.e. create partial route) it wouldn't function because of Partial flag set to true:

$route1 = new Zend_Controller_Router_Route (......); $route2 = new Zend_Controller_Router_Route (......); $route3 = new Zend_Controller_Router_Route (......);

$router->addRoute($route1); // will be broken because of Partial flag $router->addRoute($route1->chain($route2)); // ok $router->addRoute($route1->chain($route2)->chain(route3)); // ok

Why not set Partial directly in match/assemble methods of Zend_Controller_Router_Route_Chain before calling match method of chain member and set Partial back to false after that.


Posted by Matthew Weier O'Phinney (matthew) on 2009-04-23T13:15:52.000+0000

Assigning to Ben Scholzen

Posted by Ben Scholzen (dasprid) on 2009-04-24T06:49:24.000+0000

Your suggestion is possible, but would generate quuite some overhead. My prefered solution is to hand an additional $partial-parameter to the match() and assemble() method, tho this would be a change of the public API. I will make that change with the router refactoring.

Posted by Anjey Lobas (anjey) on 2009-04-24T09:58:20.000+0000

Well to minimize overhead there could be also another possible solution:

Remove partial flag, instead of using partial flag check in match/assemble instanceof caller object (If caller is instanceof Router_Abstract -- path is NOT partial, if instanceof Router_Route_Abstract -- path is partial),

Also your solution with default value of partial === null (which will then use isPartial object flag) would be fine and retain backward compatibility

Regards Anjey

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.