Skip to content

Commit

Permalink
Add Moodle 4.5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Fragonite committed Nov 28, 2024
1 parent f2e9aa7 commit 8fe7e3a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
20 changes: 20 additions & 0 deletions classes/hook_callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

namespace tool_redirects;

defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot . '/admin/tool/redirects/lib.php');

/**
* Hook callbacks for tool_redirects.
*
Expand All @@ -34,4 +38,20 @@ class hook_callbacks {
public static function before_http_headers(\core\hook\output\before_http_headers $hook): void {
\tool_redirects\helper::redirect_from_rules();
}

/**
* Listener for the after_config hook.
*
* @param \core\hook\after_config $hook
*/
public static function after_config(\core\hook\after_config $hook): void {
global $CFG;

if (during_initial_install() || isset($CFG->upgraderunning)) {
// Do nothing during installation or upgrade.
return;
}

tool_redirects_after_config();
}
}
4 changes: 4 additions & 0 deletions db/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@
'callback' => '\tool_redirects\hook_callbacks::before_http_headers',
'priority' => 0,
],
[
'hook' => \core\hook\after_config::class,
'callback' => '\tool_redirects\hook_callbacks::after_config',
],
];
3 changes: 3 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ function tool_redirects_before_http_headers() {
/**
* Redirect users based on configuration.
*
* This is a legacy callback that is used for compatibility with older Moodle versions.
* Moodle 4.5+ will use tool_redirects\hook_callbacks::after_config instead.
*
* @throws \moodle_exception
*/
function tool_redirects_after_config() {
Expand Down
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024052400;
$plugin->release = 2024052400; // Match release exactly to version.
$plugin->version = 2024112800;
$plugin->release = 2024112800; // Match release exactly to version.
$plugin->requires = 2017051500; // Moodle 3.3.
$plugin->component = 'tool_redirects';
$plugin->maturity = MATURITY_STABLE;
$plugin->supported = [33, 404]; // Supports Moodle 3.5 or later.
$plugin->supported = [33, 405]; // Supports Moodle 3.5 or later.

0 comments on commit 8fe7e3a

Please sign in to comment.