Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-tool_lifecycle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-tool_lifecycle
Commits
30abb343
Commit
30abb343
authored
4 years ago
by
Justus Dieckmann
Committed by
Justus Dieckmann
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Abort and delete processes whose courses got deleted
parent
c093f63d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
classes/local/manager/process_manager.php
+16
-0
16 additions, 0 deletions
classes/local/manager/process_manager.php
db/events.php
+32
-0
32 additions, 0 deletions
db/events.php
step/lib.php
+9
-0
9 additions, 0 deletions
step/lib.php
with
57 additions
and
0 deletions
classes/local/manager/process_manager.php
+
16
−
0
View file @
30abb343
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
*/
*/
namespace
tool_lifecycle\local\manager
;
namespace
tool_lifecycle\local\manager
;
use
core\event\course_deleted
;
use
tool_lifecycle
\local\entity\process
;
use
tool_lifecycle
\local\entity\process
;
use
tool_lifecycle\event\process_proceeded
;
use
tool_lifecycle\event\process_proceeded
;
use
tool_lifecycle\event\process_rollback
;
use
tool_lifecycle\event\process_rollback
;
...
@@ -220,4 +221,19 @@ class process_manager {
...
@@ -220,4 +221,19 @@ class process_manager {
return
null
;
return
null
;
}
}
}
}
/**
* Callback for the course deletion observer.
* @param course_deleted $event The course deletion event.
* @throws \dml_exception
*/
public
static
function
course_deletion_observed
(
$event
)
{
$process
=
self
::
get_process_by_course_id
(
$event
->
get_data
()[
'courseid'
]);
if
(
$process
)
{
$step
=
step_manager
::
get_step_instance_by_workflow_index
(
$process
->
workflowid
,
$process
->
stepindex
);
$steplib
=
lib_manager
::
get_step_lib
(
$step
->
subpluginname
);
$steplib
->
abort_course
(
$process
);
self
::
remove_process
(
$process
);
}
}
}
}
This diff is collapsed.
Click to expand it.
db/events.php
0 → 100644
+
32
−
0
View file @
30abb343
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event observer.
*
* @package tool_lifecycle
* @copyright 2020 Justus Dieckmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined
(
'MOODLE_INTERNAL'
)
||
die
();
$observers
=
array
(
array
(
'eventname'
=>
'core\event\course_deleted'
,
'callback'
=>
'tool_lifecycle\local\manager\process_manager::course_deletion_observed'
,
)
);
This diff is collapsed.
Click to expand it.
step/lib.php
+
9
−
0
View file @
30abb343
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
*/
*/
namespace
tool_lifecycle\step
;
namespace
tool_lifecycle\step
;
use
tool_lifecycle
\local\entity\process
;
use
tool_lifecycle\local\manager\step_manager
;
use
tool_lifecycle\local\manager\step_manager
;
use
tool_lifecycle\local\response\step_response
;
use
tool_lifecycle\local\response\step_response
;
...
@@ -123,6 +124,14 @@ abstract class libbase {
...
@@ -123,6 +124,14 @@ abstract class libbase {
public
function
extend_add_instance_form_definition_after_data
(
$mform
,
$settings
)
{
public
function
extend_add_instance_form_definition_after_data
(
$mform
,
$settings
)
{
}
}
/**
* This method can be overridden. It is called when a course and the
* corresponding process get deleted.
* @param process $process the process that was aborted.
*/
public
function
abort_course
(
$process
)
{
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment