# ActionStack

The ActionStack helper allows you to push requests to the ActionStack 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.

## Invoking ActionStack Helper Initializes the ActionStack Plugin

Invoking the ActionStack helper implicitly registers the ActionStack plugin -- which means you do not need to explicitly register the ActionStack plugin to use this functionality.

## Adding a Task Using Action, Controller and Module Names

Often, it's simplest to simply specify the action, controller, and module (and optional request parameters), much as you would when calling `Zend_Controller_Action::_forward()`:

    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');
        }
    }

## Adding a Task Using a Request Object

Sometimes the OOP nature of a request object makes most sense; you can pass such an object to the ActionStack helper as well.

    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);
        }
    }