本文整理汇总了PHP中Symfony\Component\HttpKernel\Exception\FlattenException::getHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP FlattenException::getHeaders方法的具体用法?PHP FlattenException::getHeaders怎么用?PHP FlattenException::getHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpKernel\Exception\FlattenException
的用法示例。
在下文中一共展示了FlattenException::getHeaders方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showAction
/**
* Converts an Exception to a Response.
*
* @param FlattenException $exception A FlattenException instance
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance
* @param string $format The format to use for rendering (html, xml, ...)
*
* @throws \InvalidArgumentException When the exception template does not exist
*/
public function showAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
{
$this->container->get('request')->setRequestFormat($format);
$code = $exception->getStatusCode();
$params = array('status_code' => $code, 'status_text' => Response::$statusTexts[$code]);
try {
$params['auth'] = $this->container->get('security.context')->isGranted('IS_AUTHENTICATED_REMEMBERED');
} catch (\Exception $e) {
$params['auth'] = false;
}
$templating = $this->container->get('templating');
if (404 == $code) {
if ($this->container->get('request')->isXmlHttpRequest()) {
$response = new Response('You should not do that.');
} else {
$response = $templating->renderResponse('LichessBundle:Exception:notFound.html.twig', $params);
}
} else {
if ($this->container->get('request')->isXmlHttpRequest()) {
$response = new Response('Something went terribly wrong.');
} else {
$params['url'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['REQUEST_URI'];
$response = $templating->renderResponse('LichessBundle:Exception:error.html.twig', $params);
}
}
$response->setStatusCode($code);
$response->headers->replace($exception->getHeaders());
return $response;
}
示例2: showAction
/**
* Converts an Exception to a Response.
*
* @param FlattenException $exception A FlattenException instance
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance
* @param string $format The format to use for rendering (html, xml, ...)
*
* @throws \InvalidArgumentException When the exception template does not exist
*/
public function showAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
{
$this->container->get('request')->setRequestFormat($format);
// the count variable avoids an infinite loop on
// some Windows configurations where ob_get_level()
// never reaches 0
$count = 100;
$currentContent = '';
while (ob_get_level() && --$count) {
$currentContent .= ob_get_clean();
}
$templating = $this->container->get('templating');
$code = $exception->getStatusCode();
$response = $templating->renderResponse(
$this->findTemplate($templating, $format, $code, $this->container->get('kernel')->isDebug()),
array(
'status_code' => $code,
'status_text' => Response::$statusTexts[$code],
'exception' => $exception,
'logger' => $logger,
'currentContent' => $currentContent,
)
);
$response->setStatusCode($code);
$response->headers->replace($exception->getHeaders());
return $response;
}
示例3: showAction
/**
* Converts an Exception to a Response.
*
* @param FlattenException $exception A FlattenException instance
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance
* @param string $format The format to use for rendering (html, xml, ...)
*
* @throws \InvalidArgumentException When the exception template does not exist
*/
public function showAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
{
$this->container->get('request')->setRequestFormat($format);
// the count variable avoids an infinite loop on
// some Windows configurations where ob_get_level()
// never reaches 0
$count = 100;
$currentContent = '';
while (ob_get_level() && --$count) {
$currentContent .= ob_get_clean();
}
$name = $this->container->get('kernel')->isDebug() ? 'exception' : 'error';
if ($this->container->get('kernel')->isDebug() && 'html' == $format) {
$name = 'exception_full';
}
$template = 'FrameworkBundle:Exception:' . $name . '.' . $format . '.twig';
$templating = $this->container->get('templating');
if (!$templating->exists($template)) {
$this->container->get('request')->setRequestFormat('html');
$template = 'FrameworkBundle:Exception:' . $name . '.html.twig';
}
$code = $exception->getStatusCode();
$response = $templating->renderResponse($template, array('status_code' => $code, 'status_text' => Response::$statusTexts[$code], 'exception' => $exception, 'logger' => $logger, 'currentContent' => $currentContent));
$response->setStatusCode($code);
$response->headers->replace($exception->getHeaders());
return $response;
}
示例4: showAction
public function showAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
{
$statusCode = $exception->getStatusCode();
$statusText = $exception->getMessage();
$response = $this->render('GitonomyWebsiteBundle:Error:error.html.twig', array('status_code' => $statusCode, 'status_text' => $statusText));
$response->setStatusCode($statusCode);
$response->headers->replace($exception->getHeaders());
return $response;
}
示例5: errorAction
public function errorAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
{
$this->container->get('request')->setRequestFormat($format);
$response = new Response('Something is wrong');
$code = $exception->getStatusCode();
$response->setStatusCode($code);
$response->headers->replace($exception->getHeaders());
return $response;
}
示例6: showAction
/**
* Converts an Exception to a Response.
*
* @param FlattenException $exception A FlattenException instance
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance
* @param string $format The format to use for rendering (html, xml, ...)
*
* @return Response
*
* @throws \InvalidArgumentException When the exception template does not exist
*/
public function showAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
{
$this->container->get('request')->setRequestFormat($format);
$currentContent = $this->getAndCleanOutputBuffering();
$templating = $this->container->get('templating');
$code = $exception->getStatusCode();
$response = $templating->renderResponse($this->findTemplate($templating, $format, $code, $this->container->get('kernel')->isDebug()), array('status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, 'logger' => $logger, 'currentContent' => $currentContent));
$response->setStatusCode($code);
$response->headers->replace($exception->getHeaders());
return $response;
}
示例7: showAction
/**
* @param Request $request
* @param FlattenException $exception
* @param DebugLoggerInterface $logger
* @return \GoIntegro\Hateoas\Http\JsonResponse
*/
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = NULL)
{
$error = new ErrorObject();
$error->status = $exception->getStatusCode();
$error->title = $exception->getMessage();
$error->code = $exception->getCode();
$serializer = new ErrorSerializer($error);
if (500 == $error->status && NULL != $logger) {
$logger->error(sprintf(self::ERROR_LOG_MESSAGE_PATTERN, $error->title, $exception->getFile(), $exception->getLine(), $error->id));
}
return $this->createNoCacheResponse($serializer->serialize(), $error->status, $exception->getHeaders());
}
示例8: showAction
/**
* Converts an Exception to a Response.
*
* @param FlattenException $exception A FlattenException instance
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance
* @param string $format The format to use for rendering (html, xml, ...)
*
* @throws \InvalidArgumentException When the exception template does not exist
*/
public function showAction(FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
{
$this->container->get('request')->setRequestFormat($format);
$code = $exception->getStatusCode();
$params = array('status_code' => $code, 'status_text' => Response::$statusTexts[$code]);
if (404 == $code) {
if ($this->container->get('request')->isXmlHttpRequest()) {
$response = new Response('You should not do that.');
} else {
$response = $this->container->get('http_kernel')->forward('LichessOpeningBundle:Hook:index');
}
} else {
if ($this->container->get('request')->isXmlHttpRequest()) {
$response = new Response('Something went terribly wrong.');
} else {
$params['url'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['REQUEST_URI'];
$response = $this->container->get('templating')->renderResponse('LichessBundle:Exception:error.html.twig', $params);
}
}
$response->setStatusCode($code);
$response->headers->replace($exception->getHeaders());
return $response;
}