diff --git a/structure/ws_to_ts_functions.php b/structure/ws_to_ts_functions.php index ef11eab0..3869a6e9 100644 --- a/structure/ws_to_ts_functions.php +++ b/structure/ws_to_ts_functions.php @@ -18,13 +18,26 @@ * Helper functions for converting a Moodle WS structure to a TS type. */ -use core_external\external_api; -use core_external\external_function_parameters; -use core_external\external_value; -use core_external\external_warnings; -use core_external\external_files; -use core_external\external_single_structure; -use core_external\external_multiple_structure; + if (file_exists("$CFG->libdir/external/classes/external_api.php")) { + use core_external\external_api; + use core_external\external_function_parameters; + use core_external\external_value; + use core_external\external_warnings; + use core_external\external_files; + use core_external\external_single_structure; + use core_external\external_multiple_structure; +} else { + require_once("$CFG->libdir/externallib.php"); + + use external_api; + use external_function_parameters; + use external_value; + use external_warnings; + use external_files; + use external_single_structure; + use external_multiple_structure; + } + /** * Get the structure of a WS params or returns.