@@ 60-71 (lines=12) @@ | ||
57 | * @param array $output |
|
58 | * @return SS_HTTPResponse |
|
59 | */ |
|
60 | protected function getAPIResponse($output) { |
|
61 | $response = $this->getResponse(); |
|
62 | if($this->respondWithText()) { |
|
63 | $body = print_r($output, true); |
|
64 | $response->addHeader('Content-Type', 'text/plain'); |
|
65 | } else { |
|
66 | $body = Convert::raw2json($output); |
|
67 | $response->addHeader('Content-Type', 'application/json'); |
|
68 | } |
|
69 | $response->setBody($body); |
|
70 | return $response; |
|
71 | } |
|
72 | ||
73 | /** |
|
74 | * @return boolean |
@@ 143-151 (lines=9) @@ | ||
140 | * @param int $statusCode |
|
141 | * @return SS_HTTPResponse |
|
142 | */ |
|
143 | protected function getAPIResponse($output, $statusCode) { |
|
144 | $output['server_time'] = SS_Datetime::now()->format('U'); |
|
145 | $output['status_code'] = $statusCode; |
|
146 | $response = $this->getResponse(); |
|
147 | $response->addHeader('Content-Type', 'application/json'); |
|
148 | $response->setBody(json_encode($output, JSON_PRETTY_PRINT)); |
|
149 | $response->setStatusCode($statusCode); |
|
150 | return $response; |
|
151 | } |
|
152 | ||
153 | /** |
|
154 | * Decode the data submitted by the Form.jsx control. |