Merge branch 'mdl-83479-restore-hooks' of https://github.com/jaypha/moodle

This commit is contained in:
Huong Nguyen
2025-04-01 09:51:51 +07:00
23 changed files with 834 additions and 1 deletions
@@ -25,8 +25,11 @@
namespace core\task;
use core\di;
use async_helper;
use cache_helper;
use core\hook\manager;
use core_backup\hook\before_copy_course_execute;
defined('MOODLE_INTERNAL') || die();
@@ -125,6 +128,10 @@ class asynchronous_copy_task extends adhoc_task {
$shortname = $plan->get_setting('course_shortname');
$shortname->set_value($copyinfo->shortname);
// Create and dispatch a hook to allow interaction with the task immediately prior to execution.
$hook = new before_copy_course_execute($plan, $copyinfo);
di::get(manager::class)->dispatch($hook);
// Do some preflight checks on the restore.
$rc->execute_precheck();
$status = $rc->get_status();