1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect3 id="zend.controller.actionhelpers.actionstack">
<title>ActionStack</title>
<para>
The <emphasis>ActionStack</emphasis> helper allows you to push requests to the
<link linkend="zend.controller.plugins.standard.actionstack">ActionStack</link>
front controller plugin, effectively helping you create a queue of
actions to execute during the request. The helper allows you to add
actions either by specifying new request objects or
action - controller - module sets.
</para>
<note>
<title>Invoking ActionStack Helper Initializes the ActionStack Plugin</title>
<para>
Invoking the <emphasis>ActionStack</emphasis> helper implicitly registers
the <emphasis>ActionStack</emphasis> plugin -- which means you do not need
to explicitly register the <emphasis>ActionStack</emphasis> plugin to use
this functionality.
</para>
</note>
<example id="zend.controller.actionhelpers.actionstack.simple">
<title>Adding a Task Using Action, Controller and Module Names</title>
<para>
Often, it's simplest to simply specify the action, controller, and
module (and optional request parameters), much as you would when
calling <methodname>Zend_Controller_Action::_forward()</methodname>:
</para>
<programlisting language="php"><![CDATA[
class FooController extends Zend_Controller_Action
{
public function barAction()
{
// Add two actions to the stack
// Add call to /foo/baz/bar/baz
// (FooController::bazAction() with request var bar == baz)
$this->_helper->actionStack('baz',
'foo',
'default',
array('bar' => 'baz'));
// Add call to /bar/bat
// (BarController::batAction())
$this->_helper->actionStack('bat', 'bar');
}
}
]]></programlisting>
</example>
<example id="zend.controller.actionhelpers.actionstack.simple2">
<title>Adding a Task Using a Request Object</title>
<para>
Sometimes the <acronym>OOP</acronym> nature of a request object makes most sense; you
can pass such an object to the <emphasis>ActionStack</emphasis> helper as
well.
</para>
<programlisting language="php"><![CDATA[
class FooController extends Zend_Controller_Action
{
public function barAction()
{
// Add two actions to the stack
// Add call to /foo/baz/bar/baz
// (FooController::bazAction() with request var bar == baz)
$request = clone $this->getRequest();
// Don't set controller or module; use current values
$request->setActionName('baz')
->setParams(array('bar' => 'baz'));
$this->_helper->actionStack($request);
// Add call to /bar/bat
// (BarController::batAction())
$request = clone $this->getRequest();
// don't set module; use current value
$request->setActionName('bat')
->setControllerName('bar');
$this->_helper->actionStack($request);
}
}
]]></programlisting>
</example>
</sect3>
<!--
vim:se ts=4 sw=4 et:
-->
|