Skip to content

Commit

Permalink
Add pre and post bulk operation for interactive processing
Browse files Browse the repository at this point in the history
  • Loading branch information
justusdieckmann committed Feb 21, 2024
1 parent a1166ed commit 29f3ead
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions classes/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
namespace tool_lifecycle;

use tool_lifecycle\local\entity\process;
use tool_lifecycle\local\entity\trigger_subplugin;
use tool_lifecycle\event\process_triggered;
use tool_lifecycle\local\manager\process_manager;
Expand Down Expand Up @@ -154,11 +155,31 @@ public function process_courses() {
* @param int $processid Id of the process
* @return boolean if true, interaction finished.
* If false, the current step is still processing and cares for displaying the view.
* @throws \coding_exception
* @throws \dml_exception
*/
public function process_course_interactive($processid) {
$process = process_manager::get_process_by_id($processid);
$steps = step_manager::get_step_types();
/* @var \tool_lifecycle\step\libbase[] $steplibs stores the lib classes of all step subplugins.*/
$steplibs = [];
foreach ($steps as $id => $step) {
$steplibs[$id] = lib_manager::get_step_lib($id);
$steplibs[$id]->pre_processing_bulk_operation();
}
$result = $this->process_course_interactive_recursive($process);
foreach ($steps as $id => $step) {
$steplibs[$id]->post_processing_bulk_operation();
}
return $result;
}

/**
* See process_course_interactive().
*
* @param process $process the process
* @return boolean if true, interaction finished.
* If false, the current step is still processing and cares for displaying the view.
*/
protected function process_course_interactive_recursive($process) {
$step = step_manager::get_step_instance_by_workflow_index($process->workflowid, $process->stepindex + 1);
// If there is no next step, then proceed, which will delete/finish the process.
if (!$step) {
Expand All @@ -178,7 +199,7 @@ public function process_course_interactive($processid) {
break;
case step_interactive_response::proceed():
// In case of proceed, call recursively.
return $this->process_course_interactive($processid);
return $this->process_course_interactive($process);
break;
case step_interactive_response::rollback():
delayed_courses_manager::set_course_delayed_for_workflow($process->courseid, true, $process->workflowid);
Expand Down

0 comments on commit 29f3ead

Please sign in to comment.