From fff2c7420f719ce08c61b04b54e7a890f308bd0d Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 7 Dec 2022 12:28:45 +0800 Subject: [PATCH] MDL-76583 core_external: Migrate restricted_context_exception class --- lib/external/classes/external_api.php | 1 - .../classes/restricted_context_exception.php | 33 +++++++++++++++++++ lib/externallib.php | 21 +----------- 3 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 lib/external/classes/restricted_context_exception.php diff --git a/lib/external/classes/external_api.php b/lib/external/classes/external_api.php index fe1bfc9bcbe..769c8c69497 100644 --- a/lib/external/classes/external_api.php +++ b/lib/external/classes/external_api.php @@ -28,7 +28,6 @@ use external_value; use invalid_parameter_exception; use invalid_response_exception; use moodle_exception; -use restricted_context_exception; /** * Base class for external api methods. diff --git a/lib/external/classes/restricted_context_exception.php b/lib/external/classes/restricted_context_exception.php new file mode 100644 index 00000000000..ff39c6a80be --- /dev/null +++ b/lib/external/classes/restricted_context_exception.php @@ -0,0 +1,33 @@ +. + +namespace core_external; + +/** + * Exception indicating user is not allowed to use external function in the current context. + * + * @package core_external + * @copyright 2009 Petr Skodak + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class restricted_context_exception extends \moodle_exception { + /** + * Constructor + */ + public function __construct() { + parent::__construct('restrictedcontextexception', 'error'); + } +} diff --git a/lib/externallib.php b/lib/externallib.php index a2d4e1e786c..29077aa4251 100644 --- a/lib/externallib.php +++ b/lib/externallib.php @@ -25,33 +25,14 @@ defined('MOODLE_INTERNAL') || die(); -/** - * Exception indicating user is not allowed to use external function in the current context. - * - * @package core_webservice - * @copyright 2009 Petr Skodak - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @since Moodle 2.0 - */ -class restricted_context_exception extends moodle_exception { - /** - * Constructor - * - * @since Moodle 2.0 - */ - function __construct() { - parent::__construct('restrictedcontextexception', 'error'); - } -} - class_alias(\core_external\external_api::class, 'external_api'); +class_alias(\core_external\restricted_context_exception::class, 'restricted_context_exception'); class_alias(\core_external\external_description::class, 'external_description'); class_alias(\core_external\external_value::class, 'external_value'); class_alias(\core_external\external_single_structure::class, 'external_single_structure'); class_alias(\core_external\external_multiple_structure::class, 'external_multiple_structure'); class_alias(\core_external\external_function_parameters::class, 'external_function_parameters'); - /** * Generate a token *