It would be within a browser. For example, suppose this was a storefront and everytime a product was purchased, units are subtracted from inventory. What if you wanted it to check each time against a predefined threshold of inventory and run a re-stock process which would automatically put in an order to a supplier. That re-stock process doesn't need to be visible to the user, nor does it need to run as a cron job or each time a single order is placed. Only when certain criteria are met.
Hence I could see the logic being something like "if foo->quantity < X, forward to bar(controller/action)" Then bar runs and then passes back to the view in foo.
So question is, would you use redirects, forwards, pre-dispach, or what to implement this type of application logic.
--Seth
From: Hector Virgen [mailto:djvirgen@gmail.com]
Sent: Tuesday, March 31, 2009 5:38 PM
To: Atkins, Seth (RICH1:5278)
Cc: fw-mvc@lists.zend.com
Subject: Re: [fw-mvc] headless controllers
Also, note that you can instantiate your controllers manually. You just need to pass in valid request/response objects. This works out very well for cron jobs, which I have done in the past to generate/send daily newsletters.
-Hector
On Tue, Mar 31, 2009 at 1:27 PM, Seth Atkins <satkins@nortel.com> wrote:
I can't seem to find a lot of documentation on how one would typically implement a controller without a view. Yes, turning off the view is easy, but not my question.Suppose I have a background task that I want to run under certain conditions. Call it controller1/action1. And after it is done, suppose I want it to go to controller2/index. Is the typical implementation to chain these together through redirects?Like:class controller1 extends ActionController{function action1Action(){//do something$this->_redirect('/controller2/index');}}Or is it prefered to chain them together in the dispatch chain using custom pre/post dispatch methods?I know ZF has the flexibility to do it many ways, just trying to get an idea of the pros/cons of the different ways.Seth
没有评论:
发表评论