-- debussy007 <[EMAIL PROTECTED]> wrote
(on Saturday, 08 November 2008, 10:14 AM -0800):
> How can I execute several actions from one action:
>
> the follwing test will print:
> index A
> index B
> index C
> test 2 !
>
> I was expecting it to be
> index A
> test 1 !
> index B
> test 2 !
> index C
>
> function indexAction() {
> $this->logger->debug('index A');
> $this->_forward('test1');
_forward() tells the front controller that there's another action to
execute -- but it doesn't actually execute it until the current action
is done. Typically, if you want to forward, you should call:
return $this->_forward('test1');
which halts execution of the current action, and starts execution of the
next. You cannot execute multiple additional actions *within* the same
action using _forward().
You can queue multiple actions to execute at once using the ActionStack
plugin/helper.
Alternately, you can use the action() view helper to execute another
action and return the results immediately -- but there is significant
overhead to do this.
> $this->logger->debug('index B');
> $this->_forward('test2');
> $this->logger->debug('index C');
> }
> function test1Action() {
> $this->_helper->viewRenderer->setNoRender();
> $this->logger->debug('test 1 !');
> }
> function test2Action() {
> $this->_helper->viewRenderer->setNoRender();
> $this->logger->debug('test 2 !');
> }
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/