/** * @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); } }
/** * @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); }
/** * @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); }