From 717edc2a6fb8ad54ff0752bcfed47f1012c87484 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 14 Nov 2017 15:06:54 +0100 Subject: [PATCH] HFP-924 Add support for more detailed messages when using AJAX --- h5p.classes.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 3564c59..cfa3022 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -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); }