Skip to content
Snippets Groups Projects
Unverified Commit 3d70a49d authored by Tobias Reischmann's avatar Tobias Reischmann
Browse files

Added rollback, which currently just deletes the process

parent c093eecf
No related branches found
No related tags found
No related merge requests found
...@@ -94,7 +94,7 @@ class cleanup_processor { ...@@ -94,7 +94,7 @@ class cleanup_processor {
break; break;
} }
} else if ($result == step_response::rollback()) { } else if ($result == step_response::rollback()) {
// TODO: Implement Rollback! process_manager::rollback_process($process);
break; break;
} else { } else {
throw new \moodle_exception('Return code \''. var_dump($result) . '\' is not allowed!'); throw new \moodle_exception('Return code \''. var_dump($result) . '\' is not allowed!');
......
...@@ -98,7 +98,7 @@ class process_manager { ...@@ -98,7 +98,7 @@ class process_manager {
// Expected behaviour! // Expected behaviour!
debugging('Course deleted properly.'); debugging('Course deleted properly.');
} }
$DB->delete_records('tool_cleanupcourses_process', (array) $process); self::remove_process($process);
return false; return false;
} }
} }
...@@ -113,4 +113,22 @@ class process_manager { ...@@ -113,4 +113,22 @@ class process_manager {
$DB->update_record('tool_cleanupcourses_process', $process); $DB->update_record('tool_cleanupcourses_process', $process);
} }
/**
* Currently only removes the current process.
* @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.
self::remove_process($process);
}
/**
* Removes the process and all data connected to it.
* @param process $process process to be deleted.
*/
private static function remove_process($process) {
global $DB;
$DB->delete_records('tool_cleanupcourses_procdata', array('processid' => $process->id));
$DB->delete_records('tool_cleanupcourses_process', (array) $process);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment