summaryrefslogtreecommitdiff
path: root/modules/rest/helpers/rest.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/rest/helpers/rest.php')
-rw-r--r--modules/rest/helpers/rest.php19
1 files changed, 15 insertions, 4 deletions
diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php
index 2c653f21..ad6ca7c7 100644
--- a/modules/rest/helpers/rest.php
+++ b/modules/rest/helpers/rest.php
@@ -62,14 +62,25 @@ class rest_Core {
/**
* Success
*/
- static function success($response_data=null, $message=null) {
+ static function success($response_data=array(), $message=null) {
$response = array("status" => "OK");
if (!empty($message)) {
$response["message"] = (string)$message;
}
- if ($response_data) {
- $response = array_merge($response, $response_data);
- }
+ $response = array_merge($response, $response_data);
+
+ // We don't need to save the session for this request
+ Session::abort_save();
+ return json_encode($response);
+ }
+
+ /**
+ * Validation Error
+ */
+ static function validation_error($error_data) {
+ $response = array("status" => "VALIDATE_ERROR");
+ $response = array_merge($response, array("fields" => $error_data));
+
// We don't need to save the session for this request
Session::abort_save();
return json_encode($response);