Skip to content

Commit

Permalink
Merge pull request #6 from bignall/master
Browse files Browse the repository at this point in the history
Add flash messages to the response
  • Loading branch information
entomb committed Dec 2, 2013
2 parents fafbf7f + 1fd5229 commit 1a714c3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions jsonAPI/JsonApiView.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,27 @@ public function render($status=200) {

$status = intval($status);

$response = $this->all();

//append error bool
if (!$this->has('error')) {
$this->set('error', false);
$response['error'] = false;
}

//append status code
$this->set('status', $status);
$response['status'] = $status;

//add flash messages
$flash = $this->data->flash->getMessages();
if (count($flash)) {
$response['flash'] = $flash;
} else {
unset($response['flash']);
}

$app->response()->status($status);
$app->response()->header('Content-Type', 'application/json');
$app->response()->body(json_encode($this->all()));
$app->response()->body(json_encode($response));

$app->stop();
}
Expand Down

0 comments on commit 1a714c3

Please sign in to comment.