當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Handler::render方法代碼示例

本文整理匯總了PHP中Illuminate\Foundation\Exceptions\Handler::render方法的典型用法代碼示例。如果您正苦於以下問題:PHP Handler::render方法的具體用法?PHP Handler::render怎麽用?PHP Handler::render使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Foundation\Exceptions\Handler的用法示例。


在下文中一共展示了Handler::render方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param Request   $request
  * @param Exception $exception
  *
  * @return Response
  */
 public function render($request, Exception $exception)
 {
     if (!$request->is(config('jsonapi.url'))) {
         return parent::render($request, $exception);
     }
     return $this->handle($request, $exception);
 }
開發者ID:askedio,項目名稱:laravel-cruddy,代碼行數:15,代碼來源:Handler.php

示例2: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     switch (get_class($e)) {
         case "Swift_TransportException":
         case "PDOException":
             $errorView = "errors.500_config";
             break;
         case "ErrorException":
             $errorView = "errors.500";
             break;
         case "Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException":
             return abort(400);
         default:
             $errorView = false;
             break;
     }
     if ($errorView) {
         // This makes use of a Symfony error handler to make pretty traces.
         $SymfonyDisplayer = new SymfonyDisplayer(config('app.debug'));
         $FlattenException = FlattenException::create($e);
         $SymfonyCss = $SymfonyDisplayer->getStylesheet($FlattenException);
         $SymfonyHtml = $SymfonyDisplayer->getContent($FlattenException);
         $response = response()->view($errorView, ['exception' => $e, 'error_class' => get_class($e), 'error_css' => $SymfonyCss, 'error_html' => $SymfonyHtml], 500);
         return $this->toIlluminateResponse($response, $e);
     } else {
         return parent::render($request, $e);
     }
 }
開發者ID:RustyGamer,項目名稱:infinity-next,代碼行數:35,代碼來源:Handler.php

示例3: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     switch ($e) {
         case $e instanceof NotFoundHttpException:
             return $this->renderException($e);
             break;
         case $e instanceof ModelNotFoundException:
             return $this->renderException($e);
             break;
         case $e instanceof UnauthorizedException:
             return $this->renderException($e);
             break;
         case $e instanceof NoActiveAccountException:
             return $this->renderException($e);
             break;
         case $e instanceof ConnectionNotAcceptedException:
             return $this->renderException($e);
             break;
         case $e instanceof EmailNotProvidedException:
             return $this->renderException($e);
             break;
         case $e instanceof EmailAlreadyInSystemException:
             return $this->renderException($e);
             break;
         case $e instanceof AlreadySyncedException:
             return $this->renderException($e);
             break;
         case $e instanceof CredentialsDoNotMatchException:
             return $this->renderException($e);
             break;
         default:
             return parent::render($request, $e);
     }
 }
開發者ID:vihugarcia,項目名稱:vhglaraboot,代碼行數:41,代碼來源:Handler.php

示例4: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof ModelNotFoundException || $e instanceof NotFoundHttpException) {
         return redirect(route('dashboard'));
     }
     return parent::render($request, $e);
 }
開發者ID:wyrover,項目名稱:backendl5,代碼行數:14,代碼來源:Handler.php

示例5: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     }
     if (config('app.debug')) {
         return parent::render($request, $e);
     }
     if ($e instanceof TokenMismatchException) {
         return redirect()->back()->withInput($request->except('_token'))->withErrors('A sua sessão expirou. Tente novamente.');
     }
     if (!$this->isHttpException($e)) {
         $pathInfo = $request->getPathInfo();
         $url = $request->url();
         $method = $request->method();
         $message = $e->getMessage() ?: get_class($e);
         $data = ['pathInfo' => $pathInfo, 'url' => $url, 'method' => $method, 'exception' => $message, 'input' => $request->all()];
         \Mail::send('emails.notify-webmaster', $data, function ($message) use($url) {
             $message->from('no-reply@andremiguelaa.com');
             $message->to('andremiguelaa@gmail.com', 'André Ascensão');
             $message->subject("Exception at {$url}");
         });
     }
     return parent::render($request, $e);
 }
開發者ID:andremiguelaa,項目名稱:quiz-cascata,代碼行數:32,代碼來源:Handler.php

示例6: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     // LM: 09-02-2015
     // See: http://stackoverflow.com/questions/29115184/laravel-catch-tokenmismatchexception
     if ($e instanceof \Illuminate\Session\TokenMismatchException) {
         // If the erros is a token mismatch
         xplog('A token mismatch error happend', __METHOD__);
         /* @BOOKMARK: TODO For now just log the user out when a token mismatch happens */
         return redirect(route('logout'));
     }
     // See: https://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5
     if ($this->isHttpException($e)) {
         // See: https://laracasts.com/discuss/channels/requests/laravel-5-404-page-driving-me-crazy
         switch ($e->getStatusCode()) {
             case '404':
                 return \Response::view('errors.custom.404');
                 break;
                 /*  case '500':
                         return \Response::view('errors.custom.500');   
                     break; */
             /*  case '500':
                     return \Response::view('errors.custom.500');   
                 break; */
             default:
                 return $this->renderHttpException($e);
                 break;
         }
     }
     if (config('app.debug')) {
         return $this->renderExceptionWithWhoops($e);
     }
     return parent::render($request, $e);
 }
開發者ID:rafaelgandi,項目名稱:wasabi_artisan,代碼行數:40,代碼來源:Handler.php

示例7: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if (App::environment() == 'local') {
         return parent::render($request, $e);
     }
     return response()->json(['error' => ['message' => $e->getMessage()]]);
 }
開發者ID:Temoto-kun,項目名稱:juan-n-juan,代碼行數:14,代碼來源:Handler.php

示例8: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof NotFoundHttpException) {
         return response()->view('errors/404', [], 404);
     }
     return parent::render($request, $e);
 }
開發者ID:minhajCSE,項目名稱:teleaus-dev,代碼行數:14,代碼來源:Handler.php

示例9: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof ModelAlreadyExistsException) {
         return redirect()->back()->withErrors([$e->getMessage()]);
     }
     return parent::render($request, $e);
 }
開發者ID:yassinbarrani,項目名稱:ThermoPiWebUI,代碼行數:14,代碼來源:Handler.php

示例10: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $exception
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $exception)
 {
     if ($exception instanceof ValidationException && $this->isApiRoute($request)) {
         return response()->error($exception->validator, 422);
     }
     return parent::render($request, $exception);
 }
開發者ID:jadjoubran,項目名稱:laravel5-angular-material-starter,代碼行數:14,代碼來源:Handler.php

示例11: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Exception $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     }
     return parent::render($request, $e);
     /* COMMENT ABOVE AND UNCOMMENT BELOW TO REDIRECT FOR CUSTOM ERROR HANDLING */
     /* if ($this->isHttpException($e)) {
                 switch ($e->getStatusCode()) {
                     // not found
                     case 404:
                         die("404 Redirect to Page not found here in app/Exceptions/Handler.php");
                         return redirect()->guest('home');
                         break;
     
                     // internal error
                     case '500':
                         die("500 Redirect to internal error page here in app/Exceptions/Handler.php");
                         return redirect()->guest('home');
                         break;
     
                     default:
                         return $this->renderHttpException($e);
                         break;
                 }
             } else {
                 return parent::render($request, $e);
             } */
 }
開發者ID:DinanathThakur,項目名稱:Flash-Sale-Ecommerce-Portal-PHP,代碼行數:36,代碼來源:Handler.php

示例12: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     //There should really be a better way to get this into json,
     //but this works as well
     if ($e instanceof ValidationException) {
         $message = "[";
         $doneOne = false;
         foreach ($e->validator->messages()->all() as $err) {
             if (!$doneOne) {
                 $doneOne = true;
             } else {
                 $message = $message . ",";
             }
             $message = $message . $err . "\n";
         }
         $message = $message . "]";
         return response($message, 400)->header("Content-Type", "application/json");
     } else {
         if ($e instanceof HttpException) {
             if ($e->getStatusCode() == 404) {
                 return response(File::get(public_path() . '/index.html'));
             }
             return $this->renderHttpException($e);
         }
     }
     return parent::render($request, $e);
 }
開發者ID:a161527,項目名稱:cs319-p2t5,代碼行數:34,代碼來源:Handler.php

示例13: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($request->is('webhook/*')) {
         return $this->getJsonResponseForException($request, $e);
     }
     return parent::render($request, $e);
 }
開發者ID:ngmy,項目名稱:webloyer,代碼行數:14,代碼來源:Handler.php

示例14: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if (in_array(get_class($e), $this->dontReport)) {
         return parent::render($request, $e);
     }
     return response()->view('errors.500', [], 500);
 }
開發者ID:chrisforrence,項目名稱:voxcom-solutions,代碼行數:14,代碼來源:Handler.php

示例15: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     /*if ($e instanceof NotFoundHttpException) {
           return redirect()->route('home');
       }*/
     return parent::render($request, $e);
 }
開發者ID:MehmetNuri,項目名稱:Blog,代碼行數:14,代碼來源:Handler.php


注:本文中的Illuminate\Foundation\Exceptions\Handler::render方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。