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


PHP Response::isServerError方法代碼示例

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


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

示例1: getParameters

 /**
  * {@inheritdoc}
  */
 public function getParameters()
 {
     $code = null;
     $codeType = null;
     $cacheable = null;
     if (null !== $this->response) {
         $code = sprintf('%d', $this->response->getStatusCode());
         $cacheable = $this->response->isCacheable() ? 'cacheable' : 'not_cacheable';
         if ($this->response->isInformational()) {
             $codeType = 'informational';
         } elseif ($this->response->isSuccessful()) {
             $codeType = 'successful';
         } elseif ($this->response->isRedirection()) {
             $codeType = 'redirection';
         } elseif ($this->response->isClientError()) {
             $codeType = 'client_error';
         } elseif ($this->response->isServerError()) {
             $codeType = 'server_error';
         } else {
             $codeType = 'other';
         }
     }
     return array('response_code' => $code, 'response_code_type' => $codeType, 'response_cacheable' => $cacheable);
 }
開發者ID:adrienbrault,項目名稱:statsd-collector,代碼行數:27,代碼來源:SymfonyResponseProvider.php

示例2: testIsServerOrClientError

 public function testIsServerOrClientError()
 {
     $response = new Response('', 404);
     $this->assertTrue($response->isClientError());
     $this->assertFalse($response->isServerError());
     $response = new Response('', 500);
     $this->assertFalse($response->isClientError());
     $this->assertTrue($response->isServerError());
 }
開發者ID:BozzaCoon,項目名稱:SPHERE-Framework,代碼行數:9,代碼來源:ResponseTest.php

示例3: logResponse

 /**
  * @param Response $response
  *
  * @return bool
  */
 private function logResponse(Response $response) : bool
 {
     return $response->isClientError() || $response->isServerError();
 }
開發者ID:Eraac,項目名稱:rest-project,代碼行數:9,代碼來源:LogRequestListener.php

示例4: makeResponse

 /**
  * Transform an exception handler's response into a Response object.
  *
  * @param  mixed      $response
  * @param  \Exception $exception
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function makeResponse($response, Exception $exception)
 {
     if (!$response instanceof Response) {
         $response = new Response($response);
     }
     if (!$response->isClientError() && !$response->isServerError() && !$response->isRedirect()) {
         if ($exception instanceof HttpExceptionInterface) {
             $response->setStatusCode($exception->getStatusCode());
             $response->headers->add($exception->getHeaders());
         } else {
             $response->setStatusCode(500);
         }
     }
     return $response;
 }
開發者ID:autarky,項目名稱:framework,代碼行數:23,代碼來源:ErrorHandlerManager.php

示例5: assertUnsuccessfulResponse

 public function assertUnsuccessfulResponse(Response $response)
 {
     $this->assertTrue($response->isClientError() || $response->isServerError());
 }
開發者ID:eugene-matvejev,項目名稱:battleship-game-api,代碼行數:4,代碼來源:ResponseAssertionSuites.php

示例6: check

 /**
  * {@inheritdoc}
  */
 public function check(Response $response, Request $request)
 {
     if ($response->isServerError()) {
         return static::DENY;
     }
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:9,代碼來源:NoServerError.php


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