如何从 ZF 中的任何操作中调用多个控制器操作?
我有一个控制器操作,我希望它在任何操作之后执行。我用这种方法编写了一个动作助手:
public function postDispatch(){
$actionstack = Zend_Controller_Action_HelperBroker::getStaticHelper('actionStack');
$actionstack->direct('myaction', 'mycontroller');
}
但它似乎陷入了循环,我的代码有什么问题?
I have a controller action and I want it to be executed after any action. I have written an action helper with this method:
public function postDispatch(){
$actionstack = Zend_Controller_Action_HelperBroker::getStaticHelper('actionStack');
$actionstack->direct('myaction', 'mycontroller');
}
But it seems that it stuck in a loop, what is wrong with my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以创建一个插件,例如:
将您想要的操作放入此插件中,这些操作最终都会被执行。
You could create a Plugin, for example:
So put the actions you want in this plugin and these aciotns will be executed after all.
您可以使用
ActionStack
操作助手,或者简单地将该方法的逻辑放入postDispatch()
中You can either use the
ActionStack
action helper, or simply put the logic of that method in yourpostDispatch()
发生的情况是,在调度 mycontroller->myaction 后再次调用 postDispatch,因此它会一次又一次地调用 mycontroller->myaction。
What happens is that the postDispatch is called again after mycontroller->myaction has been dispatched, so it calls mycontroller->myaction again and again.