From 780ba1333bbdbba029af2fdc3ca3456ea500eceb Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 7 Dec 2022 12:51:13 +0800 Subject: [PATCH] MDL-76583 core_external: Migrate external_warnings class --- lib/external/classes/external_warnings.php | 48 ++++++++++++++++++++++ lib/externallib.php | 32 +-------------- 2 files changed, 49 insertions(+), 31 deletions(-) create mode 100644 lib/external/classes/external_warnings.php diff --git a/lib/external/classes/external_warnings.php b/lib/external/classes/external_warnings.php new file mode 100644 index 00000000000..ea8260a4273 --- /dev/null +++ b/lib/external/classes/external_warnings.php @@ -0,0 +1,48 @@ +. + +namespace core_external; + +/** + * Standard Moodle web service warnings + * + * @package core_webservice + * @copyright 2012 Jerome Mouneyrac + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @since Moodle 2.3 + */ +class external_warnings extends external_multiple_structure { + + /** + * Constructor + * + * @since Moodle 2.3 + */ + public function __construct($itemdesc = 'item', $itemiddesc = 'item id', + $warningcodedesc = 'the warning code can be used by the client app to implement specific behaviour') { + + parent::__construct( + new external_single_structure( + array( + 'item' => new external_value(PARAM_TEXT, $itemdesc, VALUE_OPTIONAL), + 'itemid' => new external_value(PARAM_INT, $itemiddesc, VALUE_OPTIONAL), + 'warningcode' => new external_value(PARAM_ALPHANUM, $warningcodedesc), + 'message' => new external_value(PARAM_RAW, + 'untranslated english message to explain the warning') + ), 'warning'), + 'list of warnings', VALUE_OPTIONAL); + } +} diff --git a/lib/externallib.php b/lib/externallib.php index 4a69a6ffbb2..e176edad57e 100644 --- a/lib/externallib.php +++ b/lib/externallib.php @@ -34,6 +34,7 @@ class_alias(\core_external\external_multiple_structure::class, 'external_multipl class_alias(\core_external\external_function_parameters::class, 'external_function_parameters'); class_alias(\core_external\util::class, 'external_util'); class_alias(\core_external\external_files::class, 'external_files'); +class_alias(\core_external\external_warnings::class, 'external_warnings'); /** * Generate a token @@ -132,37 +133,6 @@ function external_delete_descriptions($component) { $DB->delete_records('external_functions', array('component'=>$component)); } -/** - * Standard Moodle web service warnings - * - * @package core_webservice - * @copyright 2012 Jerome Mouneyrac - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @since Moodle 2.3 - */ -class external_warnings extends external_multiple_structure { - - /** - * Constructor - * - * @since Moodle 2.3 - */ - public function __construct($itemdesc = 'item', $itemiddesc = 'item id', - $warningcodedesc = 'the warning code can be used by the client app to implement specific behaviour') { - - parent::__construct( - new external_single_structure( - array( - 'item' => new external_value(PARAM_TEXT, $itemdesc, VALUE_OPTIONAL), - 'itemid' => new external_value(PARAM_INT, $itemiddesc, VALUE_OPTIONAL), - 'warningcode' => new external_value(PARAM_ALPHANUM, $warningcodedesc), - 'message' => new external_value(PARAM_RAW, - 'untranslated english message to explain the warning') - ), 'warning'), - 'list of warnings', VALUE_OPTIONAL); - } -} - /** * A pre-filled external_value class for text format. *