当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::isClientError方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\Response::isClientError方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::isClientError方法的具体用法?PHP Response::isClientError怎么用?PHP Response::isClientError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\Response的用法示例。


在下文中一共展示了Response::isClientError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的Symfony\Component\HttpFoundation\Response::isClientError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。