From 2e114a04f95e8baaec7983cdec00de49ba60e864 Mon Sep 17 00:00:00 2001 From: David Woloszyn Date: Thu, 26 Jun 2025 12:18:00 +1000 Subject: [PATCH] MDL-83519 mod_assign: Add shortlink handler Co-authored-by: Andrew Lyons --- .../mod/assign/classes/shortlink_handler.php | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 public/mod/assign/classes/shortlink_handler.php diff --git a/public/mod/assign/classes/shortlink_handler.php b/public/mod/assign/classes/shortlink_handler.php new file mode 100644 index 00000000000..5d1503166db --- /dev/null +++ b/public/mod/assign/classes/shortlink_handler.php @@ -0,0 +1,48 @@ +. + +namespace mod_assign; + +use core\shortlink_handler_interface; + +/** + * Shortlink handler for mod_assign. + * + * @package mod_assign + * @copyright 2025 Andrew Lyons + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class shortlink_handler implements shortlink_handler_interface { + #[\Override] + public function get_valid_linktypes(): array { + return [ + 'view', + ]; + } + + #[\Override] + public function process_shortlink( + string $type, + string $identifier, + ): ?\core\url { + return match ($type) { + 'view' => new \core\url('/mod/assign/view.php', [ + 'id' => $identifier, + ]), + default => null, + }; + } +}