[Solar-talk] Architecture question
Travis Swicegood
development at domain51.com
Mon Oct 16 08:50:15 PDT 2006
Hi Paul,
Busy guy this morning...
Paul M Jones wrote:
> On Oct 1, 2006, at 9:48 AM, Travis Swicegood wrote:
>
>
>> Rodrigo Moraes wrote:
>>
>>>> This isn't a case of edit() taking on two roles,
>>>> instead it's taking on the abstract role of displaying a form
>>>> that works
>>>> for both the add and edit actions.
>>>>
>>>>
>>> This is more or less what I meant (sorry if it was not clear), or
>>> am I
>>> missing your point?
>>>
>>>
>> Yes, that is what you meant. I was just re-iterating the point and
>> agreeing with you.
>>
>
> So the end result of this discussion is that, instead of embedding
> the actual add/edit/etc. logic in the action method itself, one
> should have a separate processing method to handle it. That way,
> various other methods (such as Ajax-based methods) have access to the
> add/edit logic. Is that a fair summary?
>
Yes, that's a fair summary. The action*() method becomes a dispatcher
of sorts. So actionEdit() might looks something like this:
function actionEdit($data) {
$item = $this->doPrepItem($data);
$this->handleSubmit($item);
if (!empty($this->request->post()->redirectURL)) {
$this->redirect($this->request->post()->redirectURL);
}
$this->doEditForm($data);
}
Of course, you wouldn't have to break everything out like that, but
doing something like this in a Solar_App_Abstract would allow you to
just override what's necessary to make your app do it's custom stuff.
-Travis
More information about the solar-talk
mailing list