Issues

ZF-5659: Router assemble() and default routes before dispatch

Issue Type: Bug Created: 2009-01-30T04:27:20.000+0000 Last Updated: 2009-01-30T10:02:51.000+0000 Status: Resolved Fix version(s): Reporter: Josh Ribakoff (jshpro2) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Controller

Related issues: Attachments:

Description

Hi, I noticed if you want to call assemble() before the FC dispatches the request, the default route is not present. I notice that the router initializes its default routes line 310 of the route() method on the rewrite router. Would it make more sense to have the default route initialized when the router is instantiated so that I may assemble() URLs during the bootstrapping process if I want to? I for one am going to sub-class my router and fix this, just figured there would be no down side to including this fix in upcoming releases, would there?

Comments

Posted by Matthew Weier O'Phinney (matthew) on 2009-01-30T06:39:29.000+0000

We do not register the default route when the router is initialized for several reasons. First, some developers choose not to use the default route, and this would add overhead. Second, some developers register their own default route -- again, having the ZF implementation instantiated would add overhead. Finally, it's entirely possible that a routeStartup() plugin would register additional routes -- meaning that calling assemble() from the bootstrap may or may not work if the routes have not yet been registered.

Won't fix.

Posted by Josh Ribakoff (jshpro2) on 2009-01-30T07:12:07.000+0000

I understand what you're saying and that's a good point, but what about registering the default route if the programmer calls assemble() , if no route is found it could try to register the default route and try to fly with that, before throwing an exception? Then there is no performance overhead. The use case for this is that someone could want to instantiate a "navigation" model in a controller plugin or directly in the bootstrap, what would your proposed alternative be, other then sub classing the router for this workaround? subclass the action controller and instantiate the model there instead?

Posted by Matthew Weier O'Phinney (matthew) on 2009-01-30T09:52:14.000+0000

I would instantiate such a model in a dispatchLoopStartup() plugin - which ensures that the router has already fired (and hence all routes are defined). From there, you can pull the router from the front controller, and pass it to your model.

Posted by Josh Ribakoff (jshpro2) on 2009-01-30T10:02:51.000+0000

Sounds good, thanks for the comments

Have you found an issue?

See the Overview section for more details.

Copyright

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

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

Contacts