Skip to content
Snippets Groups Projects
Commit 6fef929a authored by Justus Dieckmann's avatar Justus Dieckmann
Browse files

Rollback implementation

parent 1cf86f06
No related branches found
No related tags found
No related merge requests found
......@@ -159,7 +159,17 @@ class process_manager {
* @param process $process process the rollback should be triggered for.
*/
public static function rollback_process($process) {
// TODO: Add logic to revert changes made by steps.
for ($i = $process->stepindex - 1; $i >= 1; $i++) {
$step = step_manager::get_step_instance_by_workflow_index($process->workflowid, $i);
$lib = lib_manager::get_step_lib($step->subpluginname);
try {
$course = get_course($process->courseid);
} catch (\dml_missing_record_exception $e) {
// Course no longer exists!
break;
}
$lib->rollback_course($process->id, $step->id, $course);
}
self::remove_process($process);
}
......
......@@ -75,6 +75,17 @@ abstract class libbase {
public function post_processing_bulk_operation() {
}
/**
* Rolls back all changes made to the course
*
* @param int $processid of the respective process.
* @param int $instanceid of the step instance.
* @param mixed $course to be rolled back.
*/
public function rollback_course($processid, $instanceid, $course) {
}
/**
* The return value should be equivalent with the name of the subplugin folder.
* @return string technical name of the subplugin
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment