2015-11-03 03:20:38 +01:00
|
|
|
<?php
|
2015-11-19 01:57:59 +01:00
|
|
|
class Response {
|
2015-11-03 03:20:38 +01:00
|
|
|
|
|
|
|
public static function respondError($errorMsg, $data = null) {
|
|
|
|
$response = array(
|
|
|
|
'status' => 'fail',
|
|
|
|
'message' => $errorMsg,
|
|
|
|
'data' => $data
|
|
|
|
);
|
|
|
|
|
|
|
|
$app = \Slim\Slim::getInstance();
|
|
|
|
$app->response()->setBody(json_encode($response));
|
2016-01-15 03:45:22 +01:00
|
|
|
$app->response()->finalize();
|
2015-11-03 03:20:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function respondSuccess($data = null) {
|
|
|
|
$response = array(
|
|
|
|
'status' => 'success',
|
|
|
|
'data' => $data
|
|
|
|
);
|
|
|
|
|
|
|
|
$app = \Slim\Slim::getInstance();
|
|
|
|
$app->response()->setBody(json_encode($response));
|
2016-01-15 03:45:22 +01:00
|
|
|
$app->response()->finalize();
|
2015-11-03 03:20:38 +01:00
|
|
|
}
|
|
|
|
}
|