Пример #1
0
 /**
  * Forward this request and response to another resource for processing.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request The servlet request to be
  * forwarded
  * @param \Symfony\Component\HttpFoundation\Response $response The servlet response to be
  * forwarded
  */
 public function doForward(\Symfony\Component\HttpFoundation\Request $request, \Symfony\Component\HttpFoundation\Response $response)
 {
     // Reset any output that has been buffered, but keep headers/cookies
     if ($response->isCommitted()) {
         if (!empty($this->log)) {
             $this->log->error('Forward on committed response');
         }
         throw new \Serphlet\Exception\IllegalStateException('Cannot forward after response has been committed');
     }
     $response->resetBuffer();
     $this->invoke($request, $response);
     \Serphlet\Application\RequestDispatcherForward::commit($request, $response, $this->context);
 }
Пример #2
0
 private function gracefulDie($exception = null)
 {
     // Attempt a graceful die
     @ob_end_clean();
     if (empty($exception)) {
         $exception = new \Exception('Unhandled PHP Exception encountered');
     }
     //        if (!empty($this->log)) {
     //            $this->log->error('Caught exception ' . $exception->getMessage());
     //            $this->log->debug($exception->getTraceAsString());
     //        }
     try {
         if (!empty($this->response) && !empty($this->request) && !empty($this->context)) {
             $this->response->sendError(\Symfony\Component\HttpFoundation\Response::SC_INTERNAL_SERVER_ERROR, $exception->getMessage());
             $this->request->setAttribute(\Serphlet\Globals::ERROR_MESSAGE_ATTR, $exception->getMessage());
             $this->request->setAttribute(\Serphlet\Globals::EXCEPTION_ATTR, $exception);
             \Serphlet\Application\RequestDispatcherForward::commit($this->request, $this->response, $this->context);
             $this->response->flushBuffer();
         }
     } catch (Exception $e) {
         //            if (!empty($this->log)) {
         //                $this->log->error('Could not handle a graceful die ' . $e->getMessage());
         //            }
     }
     exit;
 }