Skip to content

Commit 87839cf

Browse files
committed
[Workflow] Finished integration of initial_marking + deprecated support for workflow + single state markin store
1 parent 73708a6 commit 87839cf

13 files changed

+43
-186
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,15 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
282282
->fixXmlConfig('argument')
283283
->children()
284284
->enumNode('type')
285-
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3. Use "method" instead as it will be the only option in Symfony 5.0.')
286285
->values(['multiple_state', 'single_state', 'method'])
286+
->validate()
287+
->ifTrue(function ($v) { return 'method' !== $v; })
288+
->then(function ($v) {
289+
@trigger_error('Passing something else than "method" has been deprecated in Symfony 4.3.', E_USER_DEPRECATED);
290+
291+
return $v;
292+
})
293+
->end()
287294
->end()
288295
->arrayNode('arguments')
289296
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3. Use "property" instead.')
@@ -296,7 +303,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
296303
->end()
297304
->end()
298305
->scalarNode('property')
299-
->defaultNull()
306+
->defaultValue('marking')
300307
->end()
301308
->scalarNode('service')
302309
->cannotBeEmpty()
@@ -310,10 +317,6 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
310317
->ifTrue(function ($v) { return !empty($v['arguments']) && isset($v['service']); })
311318
->thenInvalid('"arguments" and "service" cannot be used together.')
312319
->end()
313-
->validate()
314-
->ifTrue(function ($v) { return !empty($v['property']) && isset($v['service']); })
315-
->thenInvalid('"property" and "service" cannot be used together.')
316-
->end()
317320
->end()
318321
->arrayNode('supports')
319322
->beforeNormalization()

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -644,14 +644,15 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
644644
// Create MarkingStore
645645
if (isset($workflow['marking_store']['type'])) {
646646
$markingStoreDefinition = new ChildDefinition('workflow.marking_store.'.$workflow['marking_store']['type']);
647-
foreach ($workflow['marking_store']['arguments'] as $argument) {
648-
$markingStoreDefinition->addArgument($argument);
649-
}
650647
if ('method' === $workflow['marking_store']['type']) {
651648
$markingStoreDefinition->setArguments([
652649
'state_machine' === $type, //single state
653-
$workflow['marking_store']['property'] ?? 'marking',
650+
$workflow['marking_store']['property'],
654651
]);
652+
} else {
653+
foreach ($workflow['marking_store']['arguments'] as $argument) {
654+
$markingStoreDefinition->addArgument($argument);
655+
}
655656
}
656657
} elseif (isset($workflow['marking_store']['service'])) {
657658
$markingStoreDefinition = new Reference($workflow['marking_store']['service']);
@@ -676,17 +677,14 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
676677
case 'state_machine' === $workflow['type']:
677678
$validator = new Workflow\Validator\StateMachineValidator();
678679
break;
679-
case 'method' === ($workflow['marking_store']['type'] ?? null):
680-
$singlePlace = $workflow['marking_store']['arguments'][0] ?? false;
681-
$validator = new Workflow\Validator\WorkflowValidator($singlePlace);
682-
break;
683680
case 'single_state' === ($workflow['marking_store']['type'] ?? null):
684681
$validator = new Workflow\Validator\WorkflowValidator(true);
685682
break;
686683
case 'multiple_state' === ($workflow['marking_store']['type'] ?? false):
687684
$validator = new Workflow\Validator\WorkflowValidator(false);
688685
break;
689686
}
687+
690688
if ($validator) {
691689
$realDefinition = (new Workflow\DefinitionBuilder($places))
692690
->addTransitions(array_map(function (Reference $ref) use ($container): Workflow\Transition {

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow-legacy.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
$container->loadFromExtension('framework', [
44
'workflows' => [
55
'legacy' => [
6-
'type' => 'workflow',
6+
'type' => 'state_machine',
7+
'marking_store' => [
8+
'type' => 'single_state',
9+
'arguments' => [
10+
'state',
11+
],
12+
],
713
'supports' => [
814
stdClass::class,
915
],

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_property_and_service.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow-legacy.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
88

99
<framework:config>
10-
<framework:workflow name="legacy" type="workflow" initial-place="draft">
10+
<framework:workflow name="legacy" type="state_machine" initial-place="draft">
11+
<framework:marking-store type="single_state">
12+
<framework:argument>state</framework:argument>
13+
</framework:marking-store>
1114
<framework:support>stdClass</framework:support>
1215
<framework:place name="draft" />
1316
<framework:place name="published" />

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
<framework:config>
1010
<framework:workflow name="article" type="workflow">
1111
<framework:initial-marking>draft</framework:initial-marking>
12-
<framework:marking-store>
13-
<framework:argument>a</framework:argument>
14-
<framework:argument>a</framework:argument>
15-
</framework:marking-store>
1612
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
1713
<framework:place>draft</framework:place>
1814
<framework:place>wait_for_journalist</framework:place>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_multiple_transitions_with_same_name.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
<framework:config>
1010
<framework:workflow name="article" type="workflow">
1111
<framework:initial-marking>draft</framework:initial-marking>
12-
<framework:marking-store type="multiple_state">
13-
<framework:argument>a</framework:argument>
14-
<framework:argument>a</framework:argument>
15-
</framework:marking-store>
1612
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
1713
<framework:place name="draft" />
1814
<framework:place name="wait_for_journalist" />

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_property_and_service.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
<framework:config>
1010
<framework:workflow name="article" type="workflow">
1111
<framework:initial-marking>draft</framework:initial-marking>
12-
<framework:marking-store type="multiple_state">
13-
<framework:argument>a</framework:argument>
14-
<framework:argument>a</framework:argument>
15-
</framework:marking-store>
12+
<framework:marking-store type="method" property="state" />
1613
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
1714
<framework:place name="draft" />
1815
<framework:place name="wait_for_journalist" />

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow-legacy.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
framework:
22
workflows:
33
legacy:
4-
type: workflow
4+
type: state_machine
5+
marking_store:
6+
type: single_state
7+
arguments:
8+
- state
59
initial_place: draft
610
supports:
711
- stdClass

0 commit comments

Comments
 (0)