Problem/Motivation
Follow-up from #2779647: Add a workflow component, ui module, and implement it in content moderation. Workflow::setTransitionFormStates()
currently does not allow having multiple workflow transitions which have (an) identical (or at least overlapping) from state(s) and an identical to state:
public function setTransitionFromStates($transition_id, array $from_state_ids) {
...
foreach ($from_state_ids as $from_state_id) {
...
if ($this->hasTransitionFromStateToState($from_state_id, $this->transitions[$transition_id]['to'])) {
$transition = $this->getTransitionFromStateToState($from_state_id, $this->transitions[$transition_id]['to']);
if ($transition_id !== $transition->id()) {
throw new \InvalidArgumentException("The '{$transition->id()}' transition already allows '$from_state_id' to '{$this->transitions[$transition_id]['to']}' transitions in workflow '{$this->id()}'");
}
}
}
...
}
The benefit of this is that given a from and to state, we can determine the transition ID.
There are valid use-cases for this, though, that are not possible because of this. Quoting @tstoeckler in #2779647-125: Add a workflow component, ui module, and implement it in content moderation:
I can see why we do this, but I can also see two reasons against it:
- Having a transition that is a superset (in terms of the from states) of another transition that is only available to privileged users. This can also be solved by making to transitions where the from states do not overlap, so this is only a half-reason, but it's not completely invalid because the superset could possibly make for a better UI in terms of labelling, etc.
- We actually have the concept of "Change classes" in our project, i.e. if you only fix a typo it triggers something different than if you only change content. This could also be solved by adding additional states (possibly with auto-transitions) so is also only a half-reason, but I wanted to bring it up.
Comments
Comment #2
tstoecklerBy the way, having mulled over this a bit, I am fine with this being marked won't fix, as I do appreciate that the current behavior avoids/prevents a lot of complexity, but wanted to open this in order to provide a place for a proper discussion.
Comment #3
timmillwoodI think this is an interesting discussion to have, I am also fine with this being "won't fix" but interested to hear real use cases.
Comment #13
LiamPower CreditAttribution: LiamPower at Catch Digital commentedEdit: Actually the transitions don't help with my use case
Comment #18
simeI am currently using Workflow Buttons module which takes a transition name and exposes it as a button. This has been working exceptionally well to give the user a much better sense of what they are trying to achieve rather than what the end moderation state will be.
For example a user sees a button [Save Progress] (the name of the transition) and this might push content from Published to Incomplete.
With this in place I can also add triggers when certain transitions are used using Workbench Email. This means that when [Save Progress] is triggered I can send an email to that says "Hey well done for saving progress, but you'll need to come back later and finish the job".
So, now I want to add a transition [Request Review] and the permissions are set such that only Managers can execute this. This transition can also move content from Published to Incomplete. This means that I can send an different email when this transition is executed ("Hey a manager asked you to review your thing"), as it has a different intention that than the transition that normal users can use.
There are a couple of considerations...
In the end, I can't understand why we needed to prevent additional transitions that cover the same FROM->TO. It doesn't make any sense why this is enforced, and if it wasn't enforce it would allow more creative ways for contrib module to leverage the "transition as a verb" idea that was lost when core replaced buttons with a state drop-down.
Comment #19
simeThis is a benefit but not critical - we can already order transitions, so determining the appropraite transition is a case of: