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


PHP Response::isEmpty方法代码示例

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


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

示例1: __invoke

 public function __invoke(Request $request, Response $response, Application $app)
 {
     if ($app->offsetExists("json-schema.describedBy") && !$response->isEmpty()) {
         if ($app["json-schema.correlationMechanism"] === "profile") {
             $contentType = $response->headers->get("Content-Type");
             $response->headers->set("Content-Type", "{$contentType}; profile=\"{$app["json-schema.describedBy"]}\"");
         } elseif ($app["json-schema.correlationMechanism"] === "link") {
             $response->headers->set("Link", "<{$app["json-schema.describedBy"]}>; rel=\"describedBy\"", false);
         } else {
             $errorMessage = "json-schema.correlationMechanism must be either \"profile\" or \"link\"";
             throw new ServiceUnavailableHttpException(null, $errorMessage);
         }
     }
 }
开发者ID:jdesrosiers,项目名称:silex-json-schema-provider,代码行数:14,代码来源:DescribedBy.php

示例2: testIsEmpty

 public function testIsEmpty()
 {
     foreach (array(204, 304) as $code) {
         $response = new Response('', $code);
         $this->assertTrue($response->isEmpty());
     }
     $response = new Response('', 200);
     $this->assertFalse($response->isEmpty());
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:9,代码来源:ResponseTest.php

示例3: isCacheable

 /**
  * @param Request $request
  * @param Response $response
  *
  * @return bool|int Will return integer code if response cannot be cached or true if it's cacheable
  */
 public function isCacheable(Request $request, Response $response)
 {
     if ($request->attributes->get('_supercache') === false) {
         return CacheManager::UNCACHEABLE_ROUTE;
     }
     if ($request->getMethod() !== 'GET') {
         return CacheManager::UNCACHEABLE_METHOD;
     }
     $queryString = $request->server->get('QUERY_STRING');
     if (!empty($queryString)) {
         return CacheManager::UNCACHEABLE_QUERY;
     }
     //Response::isCacheable() is unusable here due to expiry & code settings
     if (!$response->isSuccessful() || $response->isEmpty()) {
         return CacheManager::UNCACHEABLE_CODE;
     }
     if ($response->headers->hasCacheControlDirective('no-store')) {
         return CacheManager::UNCACHEABLE_NO_STORE_POLICY;
     }
     if ($response->headers->hasCacheControlDirective('private')) {
         return CacheManager::UNCACHEABLE_PRIVATE;
     }
     $environment = $this->container->getParameter('kernel.environment');
     if ($environment !== 'prod' && $environment !== 'dev' || !$this->container->getParameter('supercache.enable_' . $environment)) {
         return CacheManager::UNCACHEABLE_ENVIRONMENT;
     }
     return true;
 }
开发者ID:kiler129,项目名称:SupercacheBundle,代码行数:34,代码来源:ResponseHandler.php

示例4: isEmptyResponse

 /**
  * @return bool
  */
 protected function isEmptyResponse()
 {
     return !isset($this->response) || $this->response->isEmpty();
 }
开发者ID:mediamonks,项目名称:symfony-rest-api-bundle,代码行数:7,代码来源:ResponseModel.php


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