Symfony\Component\HttpFoundation\Response::isEmpty PHP Method

isEmpty() public method

Is the response empty?
public isEmpty ( ) : boolean
return boolean
    public function isEmpty()
    {
        return in_array($this->statusCode, array(204, 304));
    }

Usage Example

 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);
         }
     }
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Response::isEmpty