예제 #1
0
 /**
  * Wandelt eine ServiceResponse in eine HTTP-Response um
  * 
  * wandelt auch den komplexen Inhalt der ServiceResponse um. D. h. unsere HTTP-Response ist dann eine "dumme" Response
  * @return Psc\Net\HTTP\Response
  */
 public function fromService(ServiceResponse $response, Request $request)
 {
     if ($response->getStatus() === Service::OK) {
         list($format, $contentType) = $this->decideFormat($response, $request);
         $this->headers = array('Content-Type' => $contentType . '; charset=utf-8');
         // Response Meta
         if (($meta = $response->getMetadata()) != NULL) {
             $this->headers = array_merge($this->headers, $meta->toHeaders());
         }
         return $this->convertResponse($response, $format, $contentType, $request);
     } elseif ($response->getStatus() === Service::ERROR) {
         throw new NotImplementedException('Was soll das hier aussagen? Warum keine HTTPException?');
     } else {
         throw new NotImplementedException('Der Status "%s" ist nicht bekannt.', $response->getStatus());
     }
 }