/** * Takes pure data and optionally a status code, then creates the response * * @access protected * @param array $data * @param int $http_code * @return void */ protected function response($data = array(), $http_code = 200) { if (true === $this->rest) { if (is_array($data) and empty($data) or $data == '') { $this->response->status = $this->no_data_status; return; } $rest_server = Restserver::make($data, $http_code)->format($this->rest_format)->execute(); $this->response->body = $rest_server->body; $this->response->status = $rest_server->status; if (true === $this->set_content_type) { // Set the correct format header $this->response->set_header('Content-Type', Restserver::content_type($rest_server->format)); } } else { $this->response->status = $http_code; if (null !== $this->template) { $this->template->set($data); } else { $this->response->body = $data; } } }