我目前正在阅读“Keith Pope”撰写的“Zend Framework 1.8 Web Application Development”。他告诉我们使用“ActionStack”,以便在每次请求时都会调用类别顶级菜单的控制器。该插件的源代码是:
class SF_Plugin_Action extends Zend_Controller_Plugin_Abstract
{
protected $_stack;
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
$stack = $this->getStack();
// category menu
$categoryRequest = new Zend_Controller_Request_Simple();
$categoryRequest->setControllerName('category')
->setActionName('index')
->setParam(
'responseSegment',
'categoryMain'
);
// push requests into the stack
$stack->pushStack($categoryRequest);
}
public function getStack()
{
if (null === $this->_stack) {
$front = Zend_Controller_Front::getInstance();
if (!$front->hasPlugin(
'Zend_Controller_Plugin_ActionStack'
)) {
$stack = new Zend_Controller_Plugin_ActionStack();
$front->registerPlugin($stack);
} else {
$stack = $front->getPlugin('ActionStack');
}
$this->_stack = $stack;
}
return $this->_stack;
}
}
我已经阅读了“ActionStack”插件的代码。在“postDispatch”函数中,它保存当前请求,然后在“转发”函数中,它更改当前请求的控制器、操作并设置参数。那么当前请求会发生什么?它将如何执行?
我还听说ActionStack 是邪恶的。由于我是新手,我大部分都不懂,因为他没有解释(对于新手)。为什么 ActionStack 是邪恶的?