动作堆栈(助手)
动作堆栈助手允许把请求压到动作堆栈前端控制器插件,有效地帮助你在请求期间创建一个动作队列来执行。(动作堆栈)助手允许你通过指定新的请求对象或通过“动作/控制器/模块”集合来添加动作。
调用动作堆栈助手来初始化动作堆栈插件
调用动作堆栈 助手暗中注册动作堆栈 插件 -- 这就意味着你不需要显性地注册动作堆栈 插件来用这个功能。
用动作、控制器和模块名来添加一个任务
经常地,仅仅指定动作、控制器和模块(和可选的参数)最简单,和调用Zend_Controller_Action::_forward()一样:
_helper->actionStack('baz',
'foo',
'default',
array('bar' => 'baz'));
// Add call to /bar/bat
// (BarController::batAction())
$this->_helper->actionStack('bat', 'bar');
}
}
]]>
使用请求对象添加一个任务
有时候请求对象的OOP本性很有用;你也可以传递这样一个对象给动作堆栈助手。
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);
}
}
]]>