Exemplo n.º 1
0
 /**
  * Print string to the ouput stream
  *
  * @param Entity\Response | NULL $response  On NULL print No Content
  * @return void
  */
 public function printResponse(Collection\Response $response = null)
 {
     // Response NULL means no content
     if ($response->count() === 0) {
         if (!headers_sent()) {
             header('No Content', null, 204);
         }
         return;
     }
     // Set HTTP headers
     if (!headers_sent()) {
         header('OK', null, 200);
         header('Content-Type: application/json');
         //@TODO correct status code
     }
     // print json encoded string
     $response = $this->createRawResponseFromResponse($response);
     $response = $this->protocolLayerStack->handleResponse($response);
     echo $response;
 }