當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。