本文整理汇总了PHP中Symfony\Component\Debug\ExceptionHandler::getStylesheet方法的典型用法代码示例。如果您正苦于以下问题:PHP ExceptionHandler::getStylesheet方法的具体用法?PHP ExceptionHandler::getStylesheet怎么用?PHP ExceptionHandler::getStylesheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Debug\ExceptionHandler
的用法示例。
在下文中一共展示了ExceptionHandler::getStylesheet方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Symfony\Component\HttpFoundation\Response
*/
public function render($request, Exception $e)
{
$e = FlattenException::create($e);
$handler = new SymfonyExceptionHandler(env('APP_DEBUG', false));
$decorated = $this->decorate($handler->getContent($e), $handler->getStylesheet($e));
return Response::create($decorated, $e->getStatusCode(), $e->getHeaders());
}
示例3: handleException
/**
* Convert an exception to a response
*
* @param \Exception $exception
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handleException($exception)
{
if (!$exception instanceof FlattenException) {
$exception = FlattenException::create($exception);
}
$handler = new BaseExceptionHandler($this->debug);
$decorated = $this->decorate($handler->getContent($exception), $handler->getStylesheet($exception));
return new Response($decorated, $exception->getStatusCode(), $exception->getHeaders());
}
示例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 ErrorException) {
// 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);
return response()->view('errors.500', ['error' => $e, 'error_css' => $SymfonyCss, 'error_html' => $SymfonyHtml], 500);
} else {
return parent::render($request, $e);
}
}
示例5: cssAction
/**
* Renders the exception panel stylesheet for the given token.
*
* @param string $token The profiler token
*
* @return Response A Response instance
*
* @throws NotFoundHttpException
*/
public function cssAction($token)
{
if (null === $this->profiler) {
throw new NotFoundHttpException('The profiler must be enabled.');
}
$this->profiler->disable();
$exception = $this->profiler->loadProfile($token)->getCollector('exception')->getException();
$template = $this->getTemplate();
if (!$this->templateExists($template)) {
$handler = new ExceptionHandler($this->debug, $this->twig->getCharset());
return new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css'));
}
return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css'));
}
示例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)
{
if ($e instanceof HttpResponseException) {
return $e->getResponse();
} elseif ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
} elseif ($e instanceof AuthorizationException) {
$e = new HttpException(403, $e->getMessage());
} elseif ($e instanceof ValidationException && $e->getResponse()) {
return $e->getResponse();
}
$fe = FlattenException::create($e);
$handler = new SymfonyExceptionHandler(env('APP_DEBUG', false));
$decorated = $this->decorate($handler->getContent($fe), $handler->getStylesheet($fe));
$response = new Response($decorated, $fe->getStatusCode(), $fe->getHeaders());
$response->exception = $e;
return $response;
}
示例7: convertExceptionToResponse
/**
* Create a Symfony response for the given exception.
*
* @param \Exception $e
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function convertExceptionToResponse(Exception $e)
{
$e = FlattenException::create($e);
$handler = new SymfonyExceptionHandler(config('app.debug'));
$decorated = $this->decorate($handler->getContent($e), $handler->getStylesheet($e));
return SymfonyResponse::create($decorated, $e->getStatusCode(), $e->getHeaders());
}
示例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)
{
$errorView = false;
$errorEmail = false;
switch (get_class($e)) {
case "App\\Exceptions\\TorClearnet":
$errorView = "errors.403_tor_clearnet";
break;
case "Swift_TransportException":
case "PDOException":
$errorView = "errors.500_config";
$errorEmail = true;
break;
case "ErrorException":
case "Symfony\\Component\\Debug\\Exception\\FatalThrowableError":
$errorView = "errors.500";
$errorEmail = true;
break;
case "Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException":
return abort(400);
case "Predis\\Connection\\ConnectionException":
$errorView = "errors.500_predis";
$errorEmail = true;
break;
default:
$errorView = false;
break;
}
if (env('APP_DEBUG', false)) {
$errorView = false;
}
$errorEmail = $errorEmail && env('MAIL_ADDR_ADMIN', false) && env('MAIL_ADMIN_SERVER_ERRORS', false);
if ($errorEmail) {
// This makes use of a Symfony error handler to make pretty traces.
$SymfonyDisplayer = new SymfonyDisplayer(true);
$FlattenException = isset($FlattenException) ? $FlattenException : FlattenException::create($e);
$SymfonyCss = $SymfonyDisplayer->getStylesheet($FlattenException);
$SymfonyHtml = $SymfonyDisplayer->getContent($FlattenException);
$data = ['exception' => $e, 'error_class' => get_class($e), 'error_css' => $SymfonyCss, 'error_html' => $SymfonyHtml];
Mail::send('emails.error', $data, function ($message) {
$to = env('SITE_NAME', 'Infinity Next') . " Webaster";
$subject = env('SITE_NAME', 'Infinity Next') . " Error";
$subject .= " " . Request::url() ?: "";
$message->to(env('MAIL_ADDR_ADMIN', false), $to);
$message->subject($subject);
});
}
if ($errorView) {
// Duplicating logic in $errorEmail because output is completely
// diffrent without app.debug enabled. I always want a stack trace
// in my emails!
$SymfonyDisplayer = new SymfonyDisplayer(config('app.debug'));
$FlattenException = isset($FlattenException) ? $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);
}
return parent::render($request, $e);
}
示例9: originalConvertExceptionToResponseWithDebugEnabled
protected function originalConvertExceptionToResponseWithDebugEnabled(Exception $exc)
{
// needed for emails and file logs, otherwise it will be useless
$e = FlattenException::create($exc);
$handler = new SymfonyExceptionHandler(true);
$decorated = $this->decorate($handler->getContent($e), $handler->getStylesheet($e));
return SymfonyResponse::create($decorated, $e->getStatusCode(), $e->getHeaders());
}