Is it possible that this is a problem better solved with class
inheritance and extension rather than an overly complicated routing
structure? Often, I find it's the case that when insurmountable
roadblocks are encountered, it's due to a rather abstract architectural
issue, rather than otherwise. Occasionally, it is worth looking at an
entirely different approach to the fundamental architecture of your
software rather than attempting to shoe-horn some stop-gap fix in the
middle of it.
For example, the custom shopping cart controller could extend the class
of the default shopping cart controller.
For your custom processing logic in the addAction, simply do it; then
call parent::addAction();
jlevy wrote:
Good day,
I've got a bit of an issue I'm trying to resolve. My goals are as follows:
For particular actions, I want a particular module to handle the request,
otherwise, I want the default module to handle the request. Please read on
for more details.
I have two modules, Default, and ACME.
Default represents a 'generic' customer. Basically, if you don't match
certain criteria, you use default module. If you hit the site as
"www.myfancystorefront.com", you go "Default". "demo.myfancystorefront.com",
also, "Defaut" module kicks in.
If, however, you hit a particular URL, "acme.myfancystorefront.com", I load
up additional routes into the Front Controller. The routes I add don't have
matching controllers & actions in the Default module. All has been working
quite well.
Each module has a "ShoppingCart" controller,
- Default_ShoppingCartController
- ACME_ShoppingCartController
The Default shopping cart controller has actions:
- index
- add
- list
The Custom shopping cart has but one action,
- add
What I am attempting to figure out is how to always route ACME "customer" to
the Default "Shopping Cart" controller for actions: "index", and "list". I
want the ADD action, however, to be routed to the ACME_ShoppingCart
controller. There is cusomized processing logic that I perform on these ACME
orders. Once this customized logic has been performed, I want to route back
to Default_ShoppingCart ADD action to finish up the rest of the process.
Now. I know how to _forward() and all that jazz, so the last step in my
issue is of no real concern. What I'm running into is that I cannot seem to
determine
- which router type to set up in ACME.ini (routes configurations)
- Why I *always* seem to call Default_ShoppingCartController::addAction()
instead of ACME_ShoppingCartController::addAction().
My current route is as follows:
[routes]
... lots of other routes...
routes.shopping.type = "Zend_Controller_Route_Static"
routes.shopping.route = "shoppingcart"
routes.defaults.module = "ACME"
routes.defaults.controller = "shoppingcart"
routes.defaults.action = "index"
If anyone can offer some assitance I would be most appreciative. Concrete
examples, even if brief, would also help me immeasurably.
I will be monitoring this thread very closely, so if I can provide more
information, please, don't hesitate to ask.
Thanks!