如何在 Zend Framework 进程中调用其他控制器并检索它们的渲染视图?
我有以下设置:
一个无限运行的 PHP 进程,它查看包含模块名称、控制器名称、操作名称和参数数组的作业队列。
对于每个作业,我想调用给定的控制器操作并检索渲染的视图以进行进一步处理。
我正在考虑为每个作业引导一个 Zend_Application 实例,但不太确定如何处理其余的。也许还有更好的方法。
所以我的问题是:
如何在 Zend Framework 进程中调用其他控制器并检索它们的渲染视图?
提前感谢大家!
I have the following setup:
An endless running PHP process that looks at a job queue which contains module names, controller names, action names and a parameter array.
For every job I want to call the given controllers action and retrieve the rendered view for further processing.
I was thinking about bootstrapping an instance of Zend_Application for every job but not exactly sure on how to handle the rest. Maybe there is also a better way.
So my question is:
How do I call other Controllers within a Zend Framework Process and retrieve their rendered view?
Thanks to everyone in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为采用 Front_Controller 并发送新请求是最好的选择。
像这样的东西,来自你的控制器(不是工作代码):
它可能不是那么简单,但需要考虑......
I would think taking the Front_Controller and dispatching a new request would be the best to do.
Something like this, from your controller (not working code):
It might not be this simple, but something to think about...
http://framework.zend.com/manual/en/zend。 controller.dispatcher.html
您可以阅读此线程:在zend框架中调用其他控制器的成员函数?
http://framework.zend.com/manual/en/zend.controller.dispatcher.html
You can read this thread : Calling member function of other controller in zend framework?
您不能使用 动作视图助手?如果您想要控制器中的输出,那么您可以简单地使用
$this->view->action('someAction', 'someController');
或 ActionStack 帮助器。无论哪种情况,都要注意性能影响。请参阅 为什么 Zend Framework Actionstack 是邪恶的了解更多详情。
Could you not use an Action View Helper? If you want the output in your controller then you can simply use
$this->view->action('someAction', 'someController');
or the ActionStack helper.In either case, be aware of the performance implications though. See Why the Zend Framework Actionstack is Evil for more details.