Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre and post bulk operation for interactive processing #197

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading