From the CakePHP docs (emphasis mine):
The render() method is automatically called at the end of each requested controller action. This method performs all the view logic (using the data you’ve given in using the set() method), places the view inside its layout and serves it back to the end user.
But, if you look at the source for AppController::render
, it returns the rendered output back to the calling method. So, theoretically, you could do something like:
$this->autoRender = false;
$outp = $this->render('myView');
// do cleanup stuff
echo $outp;
exit();
As long as you have autoRender
set to false, you should be good. I've not personally tried this, but it seems like it should work like you want. Good luck!