Re: QuickForm Controller statemachine
| From: | Justin Patrin | Date: | Thu, 19 May 2005 04:07:59 +0000 |
| Subject: | Re: QuickForm Controller statemachine | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-19274@lists.php.net to get a copy of this message | ||
On 5/18/05, Ken Restivo <ken@restivo.org> wrote:
> The docs for QFC include a statemachine.php example and a few words of description about it.
> The description states that there is another way of doing this, by doing the determination of
> next/back action "at the controller level".
>
> Alas, there's no example of how exactly to do this "at the controller level",
> nor do I even understand exactly what they mean by that. Perhaps they mean subclassing the
> Controller::handle() method, or do they mean doing $controller->addAction() instead of
> $page->addAction()? It was unclear to me.
>
> The example code appears to subclass at the page level, creating (IMHO) an ugly and unreadable
> cut-and-paste of a different action object and perform() method for each page's next and back
> actions. It looks like they just copied and pasted code from HTML_QuickForm_Action_Next/Back 6
> times-- I suspect there's a better way.
>
> What I'd like to do is to be able to subclass the default Next/Back actions, create a data
> structure within it that maps out the state machine, write a few lines to walk through that
> structure to figure out which state is next, insert it somewhere into $data, then call the
> parent::perform() to do the rest.
>
> Reading over my question, I'm not sure how coherent it sounds, but after using QF for 7
> months I'm finally branching out into QFC, and trying to get my brain around it.
>
Sounds like a decent plan. You could do it pretty simply, though (I
think), by overriding handle() in each page and using the jump action
on the page you decide to go to.
If you do end up making something more, you may want to look into the
FSM package.
--
Justin Patrin