Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
workflow
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
workflow
Commits
b3b72fc9
Commit
b3b72fc9
authored
7 months ago
by
John Voskuilen
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3510613
: Fix WorkflowState->label() in workflow_state_allowed_values()
parent
066e6622
No related branches found
No related tags found
No related merge requests found
Pipeline
#438551
passed with warnings
7 months ago
Stage: build
Stage: validate
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Entity/WorkflowState.php
+1
-1
1 addition, 1 deletion
src/Entity/WorkflowState.php
workflow.module
+32
-13
32 additions, 13 deletions
workflow.module
with
33 additions
and
14 deletions
src/Entity/WorkflowState.php
+
1
−
1
View file @
b3b72fc9
...
...
@@ -157,7 +157,7 @@ class WorkflowState extends ConfigEntityBase implements WorkflowStateInterface {
/**
* {@inheritdoc}
*
*
I
s used in workflow_allowed_state_names().
*
Calls parent::label() and i
s used in workflow_allowed_state_names().
*/
public
function
__toString
()
{
$label
=
$this
->
t
(
'@label'
,
[
'@label'
=>
$this
->
label
()])
->
__toString
();
...
...
This diff is collapsed.
Click to expand it.
workflow.module
+
32
−
13
View file @
b3b72fc9
...
...
@@ -318,23 +318,41 @@ function workflow_allowed_workflow_state_names($wid = '', $grouped = FALSE) {
*/
function
workflow_state_allowed_values
(
FieldStorageDefinitionInterface
$field_storage_definition
,
?FieldableEntityInterface
$entity
=
NULL
,
&
$cacheable
=
TRUE
)
{
// State values cannot be cached since 'to_sid' and 'from_sid' have
// different options and on the Workflow History page,
// a normal widget is displayed, too.
// Also, cache is not per wid, so not possible for multiple wid systems.
// Note: $cacheable is a reference.
$cacheable
=
FALSE
;
switch
(
TRUE
)
{
case
$entity
instanceof
WorkflowTransitionInterface
&&
$entity
->
isExecuted
()
:
case
$entity
instanceof
WorkflowTransitionInterface
:
/** @var \Drupal\workflow\Entity\WorkflowTransitionInterface $entity */
$field_name
=
$field_storage_definition
->
getName
();
$state
=
match
(
$field_name
)
{
'from_sid'
=>
$entity
->
getFromState
(),
'to_sid'
=>
$entity
->
getToState
(),
};
switch
(
TRUE
)
{
case
$entity
->
isExecuted
()
:
/** @var \Drupal\workflow\Entity\WorkflowTransitionInterface $entity */
// We are on the Workflow History page/view
// and are editing an existing/executed/not-scheduled transition.
// Only the comments may be changed!
// (Or any other Views display displaying State names)
// or are editing an existing/executed/not-scheduled transition,
// where only the comments may be changed!
// The states may not be changed anymore.
$to_state
=
$entity
->
getToState
();
$allowed_options
=
[
$to_state
->
id
()
=>
$to_state
->
label
()];
$allowed_options
=
[
$state
->
id
()
=>
$state
->
label
()];
break
;
case
$entity
instanceof
WorkflowTransitionInterface
:
/** @var \Drupal\workflow\Entity\WorkflowTransitionInterface $entity */
$from_state
=
$entity
->
getFromState
();
$field_name
=
$field_storage_definition
->
getName
();
case
$field_name
==
'from_sid'
:
$allowed_options
=
[
$state
->
id
()
=>
$state
->
label
()];
break
;
case
$field_name
==
'to_sid'
:
$user
=
workflow_current_user
();
$allowed_options
=
$from_state
->
getOptions
(
$entity
,
$field_name
,
$user
);
$allowed_options
=
$state
->
getOptions
(
$entity
,
$field_name
,
$user
);
break
;
}
break
;
case
(
!
$entity
)
:
...
...
@@ -347,6 +365,7 @@ function workflow_state_allowed_values(FieldStorageDefinitionInterface $field_st
$allowed_options
=
[];
break
;
}
return
$allowed_options
;
}
...
...
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
sign in
to comment