本文整理汇总了PHP中Symfony\Component\HttpKernel\Exception\HttpException::getHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpException::getHeaders方法的具体用法?PHP HttpException::getHeaders怎么用?PHP HttpException::getHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpKernel\Exception\HttpException
的用法示例。
在下文中一共展示了HttpException::getHeaders方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderHttpException
/**
* Render the given HttpException.
*
* @param \Symfony\Component\HttpKernel\Exception\HttpException $e
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(HttpException $e)
{
$status = $e->getStatusCode();
if (view()->exists("soda-example::errors.{$status}")) {
return response()->view("soda-example::errors.{$status}", ['exception' => $e], $status, $e->getHeaders());
} else {
return response()->view("soda-example::errors.other", ['exception' => $e], $status, $e->getHeaders());
}
}
示例2:
function it_prepares_http_exceptions(HttpException $httpException)
{
$httpException->getStatusCode()->willReturn(404);
$httpException->getHeaders()->willReturn(['Header:test']);
$this->handleException($httpException);
$this->sendHttpCode()->shouldReturn(404);
$this->headers()->shouldReturn(['Header:test']);
}
示例3: renderHttpException
/**
* Функция для отображения сообщений на страницах ошибок (404, 500 etc.)
* @param HttpException $e
* @return \Illuminate\Http\Response
*/
protected function renderHttpException(HttpException $e)
{
$status = $e->getStatusCode();
if (view()->exists("errors.{$status}")) {
return response()->view("errors.{$status}", ['message' => $e->getMessage(), 'status' => $status, 'headers' => $e->getHeaders()], $status);
} else {
return $status;
}
}
示例4: renderHttpException
protected function renderHttpException(HttpException $e)
{
$status = $e->getStatusCode();
if (view()->exists($this->pathErrors . $status)) {
return response()->view($this->pathErrors . $status, ['exception' => $e], $status, $e->getHeaders());
} else {
return parent::renderHttpException($e);
}
}
示例5: renderHttpException
/**
* Render the given HttpException.
*
* @param \Symfony\Component\HttpKernel\Exception\HttpException $e
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(HttpException $e)
{
$status = $e->getStatusCode();
if (view()->exists("errors.{$status}")) {
return response()->view("errors.{$status}", ['exception' => $e], $status, $e->getHeaders());
} else {
return $this->convertExceptionToResponse($e);
}
}
示例6: renderHttpException
/**
* @param \Symfony\Component\HttpKernel\Exception\HttpException $exception
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(HttpException $exception)
{
$status = $exception->getStatusCode();
if ($this->view->exists("error::{$status}") && !$this->configuration->get('app.debug')) {
return $this->response->view("error::{$status}", ['exception' => $exception], $status, $exception->getHeaders());
} else {
return $this->convertExceptionToResponse($exception);
}
}
示例7: renderHttpException
/**
* Render the given HttpException.
*
* @param \Symfony\Component\HttpKernel\Exception\HttpException $e
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(HttpException $e)
{
$status = $e->getStatusCode();
$hoje = getdate();
$hoje2 = $hoje['year'] . '-' . $hoje['mon'] . '-' . $hoje['mday'];
$mensagem = MensagemAdm::all()->last();
$acaos = DB::table('acaos')->select('*')->where('data_sorteio', '>=', $hoje2)->where('deleted_at', null)->where('winner_id', null)->get();
$criador = DB::table('users')->select('*')->join('acaos', 'users.id', '=', 'acaos.user_id')->get();
$rifas = DB::table('rifas')->select('*')->join('users', 'rifas.user_id', '=', 'users.id')->whereNotNull('user_id')->groupby('name', 'acao_id')->get();
if (view()->exists("errors.{$status}")) {
return response()->view("errors.{$status}", ['exception' => $e, 'mensagem' => $mensagem, 'acaos' => $acaos, 'criador' => $criador, 'rifas' => $rifas], $status, $e->getHeaders());
} else {
return $this->convertExceptionToResponse($e);
}
}
示例8: handleHttpException
private function handleHttpException(HttpException $e, $code)
{
$message = array('status' => $e->getStatusCode(), 'code' => $code, 'message' => $e->getMessage());
return $this->app->json($message, $e->getStatusCode(), $e->getHeaders());
}
示例9:
function it_uses_the_headers_from_an_HttpExceptionInterface(HttpException $exception)
{
$exception->getStatusCode()->willReturn(401);
$exception->getHeaders()->willReturn(array('Foo' => 'Bar'));
$this->display($exception)->headers->get('Foo')->shouldBe('Bar');
}
示例10: createHttpExceptionResponse
/**
* Create a http response.
*
* @param HttpException $exception The exception to create a response for.
*
* @return JsonResponse
*/
private function createHttpExceptionResponse(HttpException $exception)
{
return new JsonResponse(['status' => 'ERROR', 'message' => $exception->getMessage()], $exception->getStatusCode(), $exception->getHeaders());
}
示例11: testHeadersConstructor
/**
* @dataProvider headerDataProvider
*/
public function testHeadersConstructor($headers)
{
$exception = new HttpException(200, null, null, $headers);
$this->assertSame($headers, $exception->getHeaders());
}