Reputation: 5458
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!
Upvotes: 1
Views: 5052
Reputation: 23
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.
Upvotes: 0
Reputation: 22213
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):
$frontController = $this->getFrontController();
$newRequest = new Zend_Controller_Request_Http();
$newRequest->setActionName('newAction');
$newRequest->setControllerName('newController');
$response = new Zend_Controller_Response_Http();
$frontController->dispatch($newRequest, $response);
It might not be this simple, but something to think about...
Upvotes: 2
Reputation: 764
$this->_forward('otherAction', 'otherControllerOrNull');
http://framework.zend.com/manual/en/zend.controller.dispatcher.html
You can read this thread : Calling member function of other controller in zend framework?
Upvotes: 0