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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-tool_lifecycle
Commits
0f84502f
Commit
0f84502f
authored
7 years ago
by
Tobias Reischmann
Browse files
Options
Downloads
Patches
Plain Diff
Added process_manager function for manually triggering a process
parent
25e201be
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
classes/manager/process_manager.php
+20
-2
20 additions, 2 deletions
classes/manager/process_manager.php
lang/en/tool_cleanupcourses.php
+2
-0
2 additions, 0 deletions
lang/en/tool_cleanupcourses.php
with
22 additions
and
2 deletions
classes/manager/process_manager.php
+
20
−
2
View file @
0f84502f
...
...
@@ -24,8 +24,6 @@
namespace
tool_cleanupcourses\manager
;
use
tool_cleanupcourses
\entity\process
;
use
tool_cleanupcourses\entity\trigger_subplugin
;
use
tool_cleanupcourses\manager\delayed_courses_manager
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
...
...
@@ -52,6 +50,26 @@ class process_manager {
return
null
;
}
/**
* Creates a process based on a manual trigger.
* @param $courseid int id of the course to be triggerd.
* @param $triggerid int id of the triggering trigger.
* @return process the triggered process instance.
* @throws \moodle_exception for invalid workflow definition or missing trigger.
*/
public
static
function
manually_trigger_process
(
$courseid
,
$triggerid
)
{
$trigger
=
trigger_manager
::
get_instance
(
$triggerid
);
if
(
!
$trigger
)
{
throw
new
\moodle_exception
(
'trigger_does_not_exist'
,
'tool_cleanupcourses'
);
}
$workflow
=
workflow_manager
::
get_workflow
(
$trigger
->
workflowid
);
if
(
!
$workflow
||
!
workflow_manager
::
is_active
(
$workflow
->
id
)
||
!
workflow_manager
::
is_valid
(
$workflow
->
id
)
||
$workflow
->
manual
!==
true
)
{
throw
new
\moodle_exception
(
'cannot_trigger_workflow_manually'
,
'tool_cleanupcourses'
);
}
return
self
::
create_process
(
$courseid
,
$workflow
->
id
);
}
/**
* Returns all current active processes.
* @return process[]
...
...
This diff is collapsed.
Click to expand it.
lang/en/tool_cleanupcourses.php
+
2
−
0
View file @
0f84502f
...
...
@@ -51,6 +51,8 @@ $string['invalid_workflow_details'] = 'Go to details view, to create a trigger f
$string
[
'active_workflow_not_changeable'
]
=
'The workflow instance is active. It is not possible to change any of its steps.'
;
$string
[
'active_workflow_not_removeable'
]
=
'The workflow instance is active. It is not possible to remove it.'
;
$string
[
'invalid_workflow_cannot_be_activated'
]
=
'The workflow definition is invalid, thus it cannot be activated.'
;
$string
[
'trigger_does_not_exist'
]
=
'The requested trigger could not be found.'
;
$string
[
'cannot_trigger_workflow_manually'
]
=
'The requested workflow could not be triggered manually.'
;
$string
[
'process_cleanup'
]
=
'Run the cleanup courses processes'
;
...
...
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