HFP-924 Add support for more detailed messages when using AJAX

pull/44/head
Frode Petterson 2017-11-14 15:06:54 +01:00
parent 5919b64c2a
commit 717edc2a6f
1 changed files with 14 additions and 1 deletions

View File

@ -51,6 +51,14 @@ interface H5PFrameworkInterface {
*/
public function setInfoMessage($message);
/**
* Return messages
*
* @param string $type 'info' or 'error'
* @return string[]
*/
public function getMessages($type);
/**
* Translation function
*
@ -2771,9 +2779,10 @@ class H5PCore {
* @param string $error_code An machine readable error code that a client
* should be able to interpret
* @param null|int $status_code Http response code
* @param array [$details=null] Better description of the error and possible which action to take
* @since 1.6.0
*/
public static function ajaxError($message = NULL, $error_code = NULL, $status_code = NULL) {
public static function ajaxError($message = NULL, $error_code = NULL, $status_code = NULL, $details = NULL) {
$response = array(
'success' => FALSE
);
@ -2785,6 +2794,10 @@ class H5PCore {
$response['errorCode'] = $error_code;
}
if ($details !== NULL) {
$response['details'] = $details;
}
self::printJson($response, $status_code);
}