From 6860e59449932b52b583ae07af5752a1e9ad8216 Mon Sep 17 00:00:00 2001 From: Kevin Pham Date: Wed, 5 Jul 2023 14:25:32 +1000 Subject: [PATCH] fix: add backwards compatibility layer for external_lib usage under Moodle 4.2 --- classes/external/external_api.php | 31 +++++++++++++++++++++++++ classes/external/trigger_dataflow.php | 2 +- classes/local/step/flow_web_service.php | 4 +--- version.php | 6 ++--- 4 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 classes/external/external_api.php diff --git a/classes/external/external_api.php b/classes/external/external_api.php new file mode 100644 index 00000000..9af5a87c --- /dev/null +++ b/classes/external/external_api.php @@ -0,0 +1,31 @@ +. + +namespace tool_dataflows\external; + +// Moved as part of https://tracker.moodle.org/browse/MDL-78049 so this is +// required to redirect sites using older versions of Moodle to the previous +// implementation. +// Once the base supported version is 4.2, this is no longer required. +if (class_exists(\core_external\external_api::class) && !class_exists(\external_api::class)) { + class_alias(\core_external\external_api::class, \external_api::class); +} + +/** + * Backwards compatibility class for underlying core's external_api + */ +class external_api extends \external_api { +} diff --git a/classes/external/trigger_dataflow.php b/classes/external/trigger_dataflow.php index 58a0575d..bd0562be 100644 --- a/classes/external/trigger_dataflow.php +++ b/classes/external/trigger_dataflow.php @@ -31,7 +31,7 @@ * @copyright Catalyst IT, 2023 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class trigger_dataflow extends \external_api { +class trigger_dataflow extends external_api { /** * Returns description of method parameters diff --git a/classes/local/step/flow_web_service.php b/classes/local/step/flow_web_service.php index 63144d35..55312f31 100644 --- a/classes/local/step/flow_web_service.php +++ b/classes/local/step/flow_web_service.php @@ -16,11 +16,9 @@ namespace tool_dataflows\local\step; -defined('MOODLE_INTERNAL') || die(); - use core_user; use core\session\manager; -use core_external\external_api; +use tool_dataflows\external\external_api; use moodle_exception; use Symfony\Component\Yaml\Yaml; use Throwable; diff --git a/version.php b/version.php index fe6597ee..626fed38 100644 --- a/version.php +++ b/version.php @@ -25,10 +25,10 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2023063000; -$plugin->release = 2023063000; +$plugin->version = 2023070500; +$plugin->release = 2023070500; $plugin->requires = 2017051500; // Our lowest supported Moodle (3.3.0). -$plugin->supported = [35, 401]; // Available as of Moodle 3.9.0 or later. +$plugin->supported = [35, 402]; // Available as of Moodle 3.9.0 or later. // TODO $plugin->incompatible = ; // Available as of Moodle 3.9.0 or later. $plugin->component = 'tool_dataflows'; $plugin->maturity = MATURITY_ALPHA;