New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FrameworkBundle] Allow multiple transitions with the same name #20795
Conversation
Padam87
commented
Dec 6, 2016
•
edited
edited
Q | A |
---|---|
Branch? | 3.2 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #20794 |
License | MIT |
Doc PR | - |
@@ -409,6 +409,8 @@ private function registerWorkflowConfiguration(array $workflows, ContainerBuilde | |||
|
|||
$transitions = array(); | |||
foreach ($workflow['transitions'] as $transitionName => $transition) { | |||
$transitionName = $transition['name'] ?: $transitionName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should normalise the values in the Configuration
class already to ensure that an element with the name
key is set.
4a787f3
to
d448322
Compare
ping @lyrixx |
->isRequired() | ||
->requiresAtLeastOneElement() | ||
->prototype('array') | ||
->children() | ||
->scalarNode('name')->defaultNull()->end() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
->scalarNode('name')
->isRequired()
->cannotBeEmpty()
->end()
@@ -322,6 +322,14 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode) | |||
->end() | |||
->end() | |||
->end() | |||
->validate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
->beforeNormalization()
->always()
->then(function ($transitions) {
// It's an indexed array, we let the validation occurs
if (isset($transitions[0])) {
return $transitions;
}
foreach ($transitions as $name => $transition) {
if (array_key_exists('name', $transition)) {
continue;
}
$transition['name'] = $name;
$transitions[$name] = $transition;
}
return $transitions;
})
->end()
Hello @Padam87 Thanks for your PR. I added 2 comments about the code. Could you please update your code with my patch? BTW, with my patch, there is no need to use a key anymore. All the following syntax works: transitions:
request_review:
from: draft
to:
- wait_for_journalist
- wait_for_spellchecker or transitions:
request_review:
from: draft
to:
- wait_for_journalist
- wait_for_spellchecker
name: this is the new name, it override request_review or transitions:
-
from: draft
to:
- wait_for_journalist
- wait_for_spellchecker
name: here I MUST specify a name |
We should still validate that you don't have 2 transitions with the same name and a common from node though. |
Yes, indeed
Why? it's possible to have 2 transitions, with the same "from" name. |
@lyrixx your |
Oups, yes, you are right ;) Sorry. |
But i'm not sure we should validate the "name + from" here. It should be done in the symfony/component validator instead. |
@lyrixx it indeed must be done in the workflow validator. |
@stof All validations are already done in a compiler pass ;) |
then fine. I forgot that |
d448322
to
7c86e16
Compare
Hello @Padam87 I'm sorry, I totally forgot this PR because it was not tagged with Thanks for this PR! 👍 |
Thank you @Padam87. |
… name (Padam87) This PR was merged into the 3.2 branch. Discussion ---------- [FrameworkBundle] Allow multiple transitions with the same name | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20794 | License | MIT | Doc PR | - Commits ------- 7c86e16 [FrameworkBundle] Allow multiple transactions with the same name