bug #34152 [Workflow] Made the configuration more robust for the 'property' key (lyrixx)

This PR was merged into the 4.3 branch.

Discussion
----------

[Workflow] Made the configuration more robust for the 'property' key

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #34092
| License       | MIT
| Doc PR        |

Commits
-------

0c31ff007e [Workflow] Made the configuration more robust for the 'property' key
This commit is contained in:
Nicolas Grekas 2019-10-28 17:55:19 +01:00
commit 48533ff3f1
2 changed files with 10 additions and 2 deletions

View File

@ -303,7 +303,7 @@ class Configuration implements ConfigurationInterface
->end()
->end()
->scalarNode('property')
->defaultValue('marking')
->defaultNull() // In Symfony 5.0, set "marking" as default property
->end()
->scalarNode('service')
->cannotBeEmpty()
@ -481,6 +481,14 @@ class Configuration implements ConfigurationInterface
return $v;
})
->end()
->validate()
->ifTrue(function ($v) {
return isset($v['marking_store']['property'])
&& (!isset($v['marking_store']['type']) || 'method' !== $v['marking_store']['type'])
;
})
->thenInvalid('"property" option is only supported by the "method" marking store.')
->end()
->end()
->end()
->end()

View File

@ -666,7 +666,7 @@ class FrameworkExtension extends Extension
if ('method' === $workflow['marking_store']['type']) {
$markingStoreDefinition->setArguments([
'state_machine' === $type, //single state
$workflow['marking_store']['property'],
$workflow['marking_store']['property'] ?? 'marking',
]);
} else {
foreach ($workflow['marking_store']['arguments'] as $argument) {