public function run(Request $request, array $session = array()) { $this->currentRequest = $request; ob_start(); try { $this->onStart(); $this->handleRequest($request, $session); } catch (Exception $e) { $this->onError($e); } try { $this->onEnd(); } catch (Exception $e) { $this->onError($e); } $output = ob_get_clean(); $this->response->write($output)->flush(); }