Yes all this needs to live in your Model, what you describe seems like
a reasonable place to maybe implement a hook within the order model
(or whatever model sells stuff), so when an order is placed you can
fire an event that can then be handled by your restocking logic.
Matthew has a plugin system in place in his pastebin app, you may want
to check that out.
2009/4/1 Martin Martinov <matix.bg@gmail.com>:
> 2009/4/1 Seth Atkins <satkins@nortel.com>:
>> 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.
>>
>
> I think this is application business logic and it must live in the model.
>
>> --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
>>
>> Is your background task going to run in a browser or as a cronjob?
>> 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
>>
>
>
>
> --
> Regards,
> Martin Martinov
> http://mmartinov.com/
>
>
--
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------
没有评论:
发表评论