Beispiel #1
0
 /**
  * Processes an incoming Request object, routes it to the adapter, and returns a response.
  *
  * @param   Request     $request
  * @return  Response    $response
  */
 public function handle(Request $request)
 {
     try {
         $restRequest = new RestRequest($this->config, $request->getMethod(), $request->getUri(), $request->getContent());
         $restResponse = $this->adapter->processRequest($restRequest);
     } catch (\Exception $e) {
         if (true === $this->debugEnabled()) {
             throw $e;
         }
         $restResponse = $this->adapter->handleException($e);
     }
     return new Response($restResponse->getContent(), $restResponse->getStatus(), $restResponse->getHeaders());
 }
Beispiel #2
0
 /**
  * Extracts the EntityMetadata from the raw array payload.
  *
  * @param   array               $rawPayload
  * @param   AdapterInterface    $adapter
  * @return  EntityMetadata
  */
 protected function extractMetadata(array $rawPayload, AdapterInterface $adapter)
 {
     return $adapter->getEntityMetadata($this->extractType($rawPayload));
 }