本文整理汇总了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);
}
}
}
示例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());
}
示例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;
}
示例4: isEmptyResponse
/**
* @return bool
*/
protected function isEmptyResponse()
{
return !isset($this->response) || $this->response->isEmpty();
}