コード例 #1
0
 /**
  * @param OperationResponse $response
  */
 public function handleResponse(OperationResponse $response)
 {
     // Add headers declared by the operation response
     $this->server->response()->status($response->getStatus());
     $this->server->response()->header('Access-Control-Allow-Origin', '*');
     foreach ($response->getHeaders() as $name => $val) {
         $this->server->response()->header($name, $val);
     }
     // Call output event
     $this->server->triggerEvent('output', $this->db, $this->cache);
     // Filter body content
     $body = $this->server->applyFilter('body', $response->getBody(), $this->db, $this->cache);
     // Output body
     if ($this->server->config('application.output') === 'xml') {
         $this->outputXML($body);
     } else {
         $this->outputJSON($body);
     }
 }
コード例 #2
0
ファイル: Me.php プロジェクト: NavalKishor/PHP-Rocker
 /**
  * @inheritdoc
  */
 public function exec(Server $server, ConnectionInterface $db, CacheInterface $cache)
 {
     $userData = $server->applyFilter('user.array', $this->user->toArray(), $db, $cache);
     return new OperationResponse(200, $userData);
 }
コード例 #3
0
 /**
  * @param ObjectInterface $object
  * @param \Rocker\Server $server
  * @param ConnectionInterface $db
  * @param CacheInterface $cache
  * @return mixed
  */
 protected function objectToArray($object, $server, $db, $cache)
 {
     return $server->applyFilter('object.array', $object->toArray(), $db, $cache);
 }