2
0

Zend_Controller-ActionHelpers-ActionStack.xml 3.3 KB

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