I want to execute saved request. this is what I did. I serialize a request object into db, then when user activate their account, I need to replay this request. I used this way to replay the request:
$front 开发者_如何转开发= Zend_Controller_Front::getInstance();
$front->returnResponse(true);
$response = $front->dispatch($request);
But this will always bring the user to the original requested page, which I don't want to do. I just want to execute the saved request in backend without user's notice. So how can I prevent the front_controller's dispatch action to automatically forward or render the original request's response?
I checked Zend framework, it said, set retureResponse to true, the response will be responded instead of being displayed. But it is not working like this. I digged into the frontcontroller, it seemed the dispatcher just dispatch the request directly.
So Are their any good solutions to execute the saved request object in zend framework in the backend?
Thanks
You have to wait until the end of the existing request before you can do this. If I'm understanding you right this SHOULD work.
Where you decide when to run the stored request.
Zend_Registry::set('runStoredRequest', true);
Then in your bootstrap after you have run through the initial request (at the bottom of your bootstrap) just add the following:
if(Zend_Registry::get('runStoredRequest')) {
/** RETRIEVE AND RUN STORED REQUEST **/
}
Check out the Zend_Test_PHPUnit_ControllerTestCase::dispatch(). That sounds like effectively what you're wanting to do.
精彩评论