本文整理汇总了PHP中Symfony\Component\Debug\Exception\FlattenException::getCode方法的典型用法代码示例。如果您正苦于以下问题:PHP FlattenException::getCode方法的具体用法?PHP FlattenException::getCode怎么用?PHP FlattenException::getCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Debug\Exception\FlattenException
的用法示例。
在下文中一共展示了FlattenException::getCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showAction
/**
* Converts an Exception to a Response.
*
* @param Request $request
* @param FlattenException $exception
* @return Response
*/
public function showAction(Request $request, FlattenException $exception)
{
if (is_subclass_of($exception->getClass(), 'Pagekit\\Kernel\\Exception\\HttpException')) {
$title = $exception->getMessage();
} else {
$title = __('Whoops, looks like something went wrong.');
}
$content = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
$response = App::view('system/error.php', compact('title', 'exception', 'content'));
return App::response($response, $exception->getCode(), $exception->getHeaders());
}
示例2: getContent
public function getContent(FlattenException $exception)
{
if ($exception->getStatusCode() == '500') {
$this->logger->error($exception->getMessage(), ['code' => $exception->getCode(), 'trace' => $exception->getTrace()]);
}
switch (true) {
case 404 === $exception->getStatusCode():
if (null !== $this->translator) {
$title = $this->translator->trans('Sorry, the page you are looking for could not be found.');
} else {
$title = 'Sorry, the page you are looking for could not be found.';
}
break;
case 403 === $exception->getStatusCode():
if (null !== $this->translator) {
$title = $this->translator->trans('Sorry, you do have access to the page you are looking for.');
} else {
$title = 'Sorry, you do have access to the page you are looking for.';
}
break;
case 500 === $exception->getStatusCode():
if (null !== $this->translator) {
$title = $this->translator->trans('Whoops, looks like something went wrong.');
} else {
$title = 'Whoops, looks like something went wrong.';
}
break;
case 503 === $exception->getStatusCode():
if (null !== $this->translator) {
$title = $this->translator->trans('Sorry, site is currently undergoing maintenance, come back soon.');
} else {
$title = 'Sorry, site is currently undergoing maintenance, come back soon.';
}
break;
case isset(Response::$statusTexts[$exception->getStatusCode()]):
$title = $exception->getStatusCode() . ' : ' . Response::$statusTexts[$exception->getStatusCode()];
break;
default:
if (null !== $this->translator) {
$title = $this->translator->trans('Whoops, looks like something went wrong.');
} else {
$title = 'Whoops, looks like something went wrong.';
}
}
$content = parent::getContent($exception);
$start = strpos($content, '</h1>');
$content = '<div id="sf-resetcontent" class="sf-reset">' . '<h1><span>' . $title . '</span></h1>' . substr($content, $start + 5);
return $content;
}
示例3: showAction
/**
* {@inheritdoc}
*/
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null)
{
$class = $exception->getClass();
//ignore authentication exceptions
if (strpos($class, 'Authentication') === false) {
$env = $this->factory->getEnvironment();
$currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
$layout = $env == 'prod' ? 'Error' : 'Exception';
$code = $exception->getStatusCode();
if ($code === 0) {
//thrown exception that didn't set a code
$code = 500;
}
// Special handling for oauth and api urls
if (strpos($request->getUri(), '/oauth') !== false || strpos($request->getUri(), '/api') !== false) {
$dataArray = array('error' => array('message' => $exception->getMessage(), 'code' => $exception->getCode()));
if ($env == 'dev') {
$dataArray['trace'] = $exception->getTrace();
}
return new JsonResponse($dataArray, 200);
}
if ($request->get('prod')) {
$layout = 'Error';
}
$anonymous = $this->factory->getSecurity()->isAnonymous();
$baseTemplate = 'MauticCoreBundle:Default:slim.html.php';
if ($anonymous) {
if ($templatePage = $this->factory->getTheme()->getErrorPageTemplate($code)) {
$baseTemplate = $templatePage;
}
}
$template = "MauticCoreBundle:{$layout}:{$code}.html.php";
$templating = $this->factory->getTemplating();
if (!$templating->exists($template)) {
$template = "MauticCoreBundle:{$layout}:base.html.php";
}
$statusText = isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '';
$url = $request->getRequestUri();
$urlParts = parse_url($url);
return $this->delegateView(array('viewParameters' => array('baseTemplate' => $baseTemplate, 'status_code' => $code, 'status_text' => $statusText, 'exception' => $exception, 'logger' => $logger, 'currentContent' => $currentContent, 'isPublicPage' => $anonymous), 'contentTemplate' => $template, 'passthroughVars' => array('error' => array('code' => $code, 'text' => $statusText, 'exception' => $env == 'dev' ? $exception->getMessage() : '', 'trace' => $env == 'dev' ? $exception->getTrace() : ''), 'route' => $urlParts['path'])));
}
}