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
bafc1c21
Commit
bafc1c21
authored
7 years ago
by
Tobias Reischmann
Browse files
Options
Downloads
Patches
Plain Diff
Restructured execute function to reduce cyclomatic complexity
parent
740fc1e0
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
adminlib.php
+88
-67
88 additions, 67 deletions
adminlib.php
with
88 additions
and
67 deletions
adminlib.php
+
88
−
67
View file @
bafc1c21
...
@@ -365,10 +365,46 @@ class workflow_settings {
...
@@ -365,10 +365,46 @@ class workflow_settings {
* This is the entry point for this controller class.
* This is the entry point for this controller class.
*/
*/
public
function
execute
(
$action
,
$subplugin
)
{
public
function
execute
(
$action
,
$subplugin
)
{
global
$PAGE
,
$OUTPUT
;
global
$PAGE
;
$this
->
check_permissions
();
$this
->
check_permissions
();
if
(
$action
===
ACTION_TRIGGER_INSTANCE_FORM
)
{
if
(
$action
===
ACTION_TRIGGER_INSTANCE_FORM
)
{
if
(
$this
->
handle_trigger_instance_form
())
{
return
;
}
}
// If trigger is not yet set, redirect to trigger form!
$trigger
=
trigger_manager
::
get_trigger_for_workflow
(
$this
->
workflowid
);
if
(
$trigger
===
null
)
{
$subpluginname
=
null
;
if
(
$name
=
optional_param
(
'subpluginname'
,
null
,
PARAM_ALPHA
))
{
$subpluginname
=
$name
;
}
$triggerform
=
new
form_trigger_instance
(
$PAGE
->
url
,
$this
->
workflowid
,
null
,
$subpluginname
);
$this
->
view_trigger_instance_form
(
$triggerform
);
return
;
}
// Handle other actions.
step_manager
::
handle_action
(
$action
,
$subplugin
);
workflow_manager
::
handle_action
(
$action
,
$subplugin
);
if
(
$action
===
ACTION_STEP_INSTANCE_FORM
)
{
if
(
$this
->
handle_step_instance_form
())
{
return
;
}
}
// If no action handler has printed any form yet, display the plugins tables.
$this
->
view_plugins_table
();
}
/**
* Handles actions for the trigger instance form and causes related forms to be rendered.
* @return bool True, if no further action handling or output should be conducted.
*/
private
function
handle_trigger_instance_form
()
{
global
$OUTPUT
,
$PAGE
;
$subpluginname
=
null
;
$subpluginname
=
null
;
$settings
=
null
;
$settings
=
null
;
if
(
$trigger
=
trigger_manager
::
get_trigger_for_workflow
(
$this
->
workflowid
))
{
if
(
$trigger
=
trigger_manager
::
get_trigger_for_workflow
(
$this
->
workflowid
))
{
...
@@ -399,31 +435,21 @@ class workflow_settings {
...
@@ -399,31 +435,21 @@ class workflow_settings {
// Save local subplugin settings.
// Save local subplugin settings.
settings_manager
::
save_settings
(
$trigger
->
id
,
SETTINGS_TYPE_TRIGGER
,
$data
->
subpluginname
,
$data
);
settings_manager
::
save_settings
(
$trigger
->
id
,
SETTINGS_TYPE_TRIGGER
,
$data
->
subpluginname
,
$data
);
}
}
$this
->
view_plugins_table
();
return
false
;
return
;
}
else
{
}
else
{
$this
->
view_trigger_instance_form
(
$form
);
$this
->
view_trigger_instance_form
(
$form
);
return
;
return
true
;
}
}
}
}
}
return
false
;
// If trigger is not yet set, redirect to trigger form!
$trigger
=
trigger_manager
::
get_trigger_for_workflow
(
$this
->
workflowid
);
if
(
$trigger
===
null
)
{
$subpluginname
=
null
;
if
(
$name
=
optional_param
(
'subpluginname'
,
null
,
PARAM_ALPHA
))
{
$subpluginname
=
$name
;
}
$triggerform
=
new
form_trigger_instance
(
$PAGE
->
url
,
$this
->
workflowid
,
null
,
$subpluginname
);
$this
->
view_trigger_instance_form
(
$triggerform
);
return
;
}
}
step_manager
::
handle_action
(
$action
,
$subplugin
);
/**
workflow_manager
::
handle_action
(
$action
,
$subplugin
);
* Handles actions for the trigger instance form and causes related forms to be rendered.
* @return bool True, if no further action handling or output should be conducted.
if
(
$action
===
ACTION_STEP_INSTANCE_FORM
)
{
*/
private
function
handle_step_instance_form
()
{
global
$OUTPUT
,
$PAGE
;
$steptomodify
=
null
;
$steptomodify
=
null
;
$subpluginname
=
null
;
$subpluginname
=
null
;
$stepsettings
=
null
;
$stepsettings
=
null
;
...
@@ -431,22 +457,19 @@ class workflow_settings {
...
@@ -431,22 +457,19 @@ class workflow_settings {
$steptomodify
=
step_manager
::
get_step_instance
(
$stepid
);
$steptomodify
=
step_manager
::
get_step_instance
(
$stepid
);
// If step was removed!
// If step was removed!
if
(
!
$steptomodify
)
{
if
(
!
$steptomodify
)
{
$this
->
view_plugins_table
();
return
false
;
return
;
}
}
$stepsettings
=
settings_manager
::
get_settings
(
$stepid
,
SETTINGS_TYPE_STEP
);
$stepsettings
=
settings_manager
::
get_settings
(
$stepid
,
SETTINGS_TYPE_STEP
);
}
else
if
(
$name
=
optional_param
(
'subpluginname'
,
null
,
PARAM_ALPHA
))
{
}
else
if
(
$name
=
optional_param
(
'subpluginname'
,
null
,
PARAM_ALPHA
))
{
$subpluginname
=
$name
;
$subpluginname
=
$name
;
}
else
{
}
else
{
$this
->
view_plugins_table
();
return
false
;
return
;
}
}
$form
=
new
form_step_instance
(
$PAGE
->
url
,
$steptomodify
,
$this
->
workflowid
,
$subpluginname
,
$stepsettings
);
$form
=
new
form_step_instance
(
$PAGE
->
url
,
$steptomodify
,
$this
->
workflowid
,
$subpluginname
,
$stepsettings
);
if
(
$form
->
is_cancelled
())
{
if
(
$form
->
is_cancelled
())
{
$this
->
view_plugins_table
();
return
false
;
return
;
}
else
if
(
$form
->
is_submitted
()
&&
$form
->
is_validated
()
&&
$data
=
$form
->
get_submitted_data
())
{
}
else
if
(
$form
->
is_submitted
()
&&
$form
->
is_validated
()
&&
$data
=
$form
->
get_submitted_data
())
{
// In case the workflow is active, we do not allow changes to the steps or trigger.
// In case the workflow is active, we do not allow changes to the steps or trigger.
if
(
workflow_manager
::
is_active
(
$this
->
workflowid
))
{
if
(
workflow_manager
::
is_active
(
$this
->
workflowid
))
{
...
@@ -464,14 +487,12 @@ class workflow_settings {
...
@@ -464,14 +487,12 @@ class workflow_settings {
// Save local subplugin settings.
// Save local subplugin settings.
settings_manager
::
save_settings
(
$step
->
id
,
SETTINGS_TYPE_STEP
,
$form
->
subpluginname
,
$data
);
settings_manager
::
save_settings
(
$step
->
id
,
SETTINGS_TYPE_STEP
,
$form
->
subpluginname
,
$data
);
}
}
$this
->
view_plugins_table
();
return
;
}
else
{
}
else
{
$this
->
view_step_instance_form
(
$form
);
$this
->
view_step_instance_form
(
$form
);
return
;
return
true
;
}
}
}
$this
->
view_plugins_table
()
;
return
false
;
}
}
}
}
\ No newline at end of file
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