-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Workflow] improve workflow config validation #20482
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...workBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_arguments_and_service.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; | ||
|
||
$container->loadFromExtension('framework', array( | ||
'workflows' => array( | ||
'my_workflow' => array( | ||
'marking_store' => array( | ||
'arguments' => array('a', 'b'), | ||
'service' => 'workflow_service', | ||
), | ||
'supports' => array( | ||
FrameworkExtensionTest::class, | ||
), | ||
'places' => array( | ||
'first', | ||
'last', | ||
), | ||
'transitions' => array( | ||
'go' => array( | ||
'from' => array( | ||
'first', | ||
), | ||
'to' => array( | ||
'last', | ||
), | ||
), | ||
), | ||
), | ||
), | ||
)); |
31 changes: 31 additions & 0 deletions
31
...FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_type_and_service.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; | ||
|
||
$container->loadFromExtension('framework', array( | ||
'workflows' => array( | ||
'my_workflow' => array( | ||
'marking_store' => array( | ||
'type' => 'multiple_state', | ||
'service' => 'workflow_service', | ||
), | ||
'supports' => array( | ||
FrameworkExtensionTest::class, | ||
), | ||
'places' => array( | ||
'first', | ||
'last', | ||
), | ||
'transitions' => array( | ||
'go' => array( | ||
'from' => array( | ||
'first', | ||
), | ||
'to' => array( | ||
'last', | ||
), | ||
), | ||
), | ||
), | ||
), | ||
)); |
24 changes: 24 additions & 0 deletions
24
...workBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_arguments_and_service.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:framework="http://symfony.com/schema/dic/symfony" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | ||
|
||
<framework:config> | ||
<framework:workflow name="my_workflow"> | ||
<framework:marking-store service="workflow_service"> | ||
<framework:argument>a</framework:argument> | ||
<framework:argument>a</framework:argument> | ||
</framework:marking-store> | ||
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support> | ||
<framework:place>first</framework:place> | ||
<framework:place>last</framework:place> | ||
<framework:transition name="foobar"> | ||
<framework:from>a</framework:from> | ||
<framework:to>a</framework:to> | ||
</framework:transition> | ||
</framework:workflow> | ||
</framework:config> | ||
</container> |
21 changes: 21 additions & 0 deletions
21
...FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_type_and_service.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:framework="http://symfony.com/schema/dic/symfony" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | ||
|
||
<framework:config> | ||
<framework:workflow name="my_workflow"> | ||
<framework:marking-store type="multiple_state" service="workflow_service" /> | ||
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support> | ||
<framework:place>first</framework:place> | ||
<framework:place>last</framework:place> | ||
<framework:transition name="foobar"> | ||
<framework:from>a</framework:from> | ||
<framework:to>a</framework:to> | ||
</framework:transition> | ||
</framework:workflow> | ||
</framework:config> | ||
</container> |
19 changes: 19 additions & 0 deletions
19
...workBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_arguments_and_service.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
framework: | ||
workflows: | ||
my_workflow: | ||
marking_store: | ||
arguments: | ||
- a | ||
- b | ||
service: workflow_service | ||
supports: | ||
- Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest | ||
places: | ||
- first | ||
- last | ||
transitions: | ||
go: | ||
from: | ||
- first | ||
to: | ||
- last |
17 changes: 17 additions & 0 deletions
17
...FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_type_and_service.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
framework: | ||
workflows: | ||
my_workflow: | ||
marking_store: | ||
type: multiple_state | ||
service: workflow_service | ||
supports: | ||
- Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest | ||
places: | ||
- first | ||
- last | ||
transitions: | ||
go: | ||
from: | ||
- first | ||
to: | ||
- last |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
you should check whether
arguments
is an empty array or no actually, to account for people repeating the default value of the node explicitly (needed if they overwrite the definition in a subsequent file). An empty array should not trigger the exception.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.
Good catch. However, what do you think about adding a constraint to the
arguments
node instead forbidding to configure it as an empty list?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.
An empty array is a valid value (and it is the default value of the node btw, as it is a prototyped array node)
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 cannot confirm that.
requiresAtLeastOneElement()
works as expected when playing with the fixtures I added in this PR.