Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ede6660

Browse filesBrowse files
committed
feature #30890 [Workflow] Changed initial_places to initial_marking, added property (HeahDude, lyrixx)
This PR was merged into the 4.3-dev branch. Discussion ---------- [Workflow] Changed initial_places to initial_marking, added property | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #30662 and #30656 | License | MIT | Doc PR | #30656 EUFOSSA --- * [Workflow] Changed initial_places to initial_marking, added property instead of type * [Workflow] Finished integration of initial_marking + deprecated support for workflow + single state markin store [Workflow] Deprecate worflow and single state marking --- Here is an exemple of deprecation: ``` 3x: Passing something else than "method" has been deprecated in Symfony 4.3. 1x in PhpFrameworkExtensionTest::testWorkflowLegacy from Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection 1x in XmlFrameworkExtensionTest::testWorkflowLegacy from Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection 1x in YamlFrameworkExtensionTest::testWorkflowLegacy from Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection 3x: The "framework.workflows.workflows.legacy.marking_store.arguments" configuration key has been deprecated in Symfony 4.3. Use "property" instead. 1x in PhpFrameworkExtensionTest::testWorkflowLegacy from Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection 1x in XmlFrameworkExtensionTest::testWorkflowLegacy from Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection 1x in YamlFrameworkExtensionTest::testWorkflowLegacy from Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection 3x: The "framework.workflows.workflows.legacy.initial_place" configuration key has been deprecated in Symfony 4.3, use the "initial_marking" configuration key instead. 1x in PhpFrameworkExtensionTest::testWorkflowLegacy from Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection 1x in XmlFrameworkExtensionTest::testWorkflowLegacy from Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection 1x in YamlFrameworkExtensionTest::testWorkflowLegacy from Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection ``` Commits ------- 0393535 [Workflow] Deprecate worflow and single state marking 87839cf [Workflow] Finished integration of initial_marking + deprecated support for workflow + single state markin store 73708a6 [Workflow] Changed initial_places to initial_marking, added property instead of type
2 parents f0786bb + 0393535 commit ede6660
Copy full SHA for ede6660

37 files changed

+228
-167
lines changed

‎UPGRADE-4.3.md

Copy file name to clipboardExpand all lines: UPGRADE-4.3.md
+35-9Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,6 @@ Workflow
166166
initial_places: [draft]
167167
```
168168

169-
Yaml
170-
----
171-
172-
* Using a mapping inside a multi-line string is deprecated and will throw a `ParseException` in 5.0.
173-
174169
Workflow
175170
--------
176171

@@ -202,19 +197,22 @@ Workflow
202197
```yaml
203198
framework:
204199
workflows:
200+
type: workflow
205201
article:
206202
marking_store:
207203
type: multiple
204+
arguments: states
208205
```
209206

210207
After:
211208
```yaml
212209
framework:
213210
workflows:
211+
type: workflow
214212
article:
215213
marking_store:
216214
type: method
217-
215+
property: states
218216
```
219217

220218
* `SingleStateMarkingStore` is deprecated. Use `MethodMarkingStore` instead.
@@ -225,16 +223,44 @@ Workflow
225223
workflows:
226224
article:
227225
marking_store:
228-
type: single
226+
arguments: state
229227
```
230228

231229
After:
232230
```yaml
233231
framework:
234232
workflows:
233+
type: state_machine
235234
article:
236235
marking_store:
237236
type: method
238-
arguments:
239-
- true
237+
property: state
238+
```
239+
240+
* Using a workflow with a single state marking is deprecated. Use a state machine instead.
241+
242+
Before:
243+
```yaml
244+
framework:
245+
workflows:
246+
article:
247+
type: workflow
248+
marking_store:
249+
type: single_state
240250
```
251+
252+
After:
253+
```yaml
254+
framework:
255+
workflows:
256+
article:
257+
type: state_machine
258+
marking_store:
259+
# type: single_state # Since the single_state marking store is deprecated, use method instead
260+
type: method
261+
```
262+
263+
Yaml
264+
----
265+
266+
* Using a mapping inside a multi-line string is deprecated and will throw a `ParseException` in 5.0.

‎UPGRADE-5.0.md

Copy file name to clipboardExpand all lines: UPGRADE-5.0.md
+62-2Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,68 @@ Workflow
388388
* `ClassInstanceSupportStrategy` has been removed, use `InstanceOfSupportStrategy` instead.
389389
* `MarkingStoreInterface::setMarking()` has a third argument: `array $context = []`.
390390
* Removed support of `initial_place`. Use `initial_places` instead.
391-
* `MultipleStateMarkingStore` has been removed.
392-
* `SingleStateMarkingStore` has been removed.
391+
* `MultipleStateMarkingStore` has been removed. Use `MethodMarkingStore` instead.
392+
393+
Before:
394+
```yaml
395+
framework:
396+
workflows:
397+
type: workflow
398+
article:
399+
marking_store:
400+
type: multiple
401+
arguments: states
402+
```
403+
404+
After:
405+
```yaml
406+
framework:
407+
workflows:
408+
type: workflow
409+
article:
410+
marking_store:
411+
property: states
412+
```
413+
* `SingleStateMarkingStore` has been removed. Use `MethodMarkingStore` instead.
414+
415+
Before:
416+
```yaml
417+
framework:
418+
workflows:
419+
article:
420+
marking_store:
421+
arguments: state
422+
```
423+
424+
After:
425+
```yaml
426+
framework:
427+
workflows:
428+
article:
429+
marking_store:
430+
property: state
431+
```
432+
433+
434+
* Support for using a workflow with a single state marking is dropped. Use a state machine instead.
435+
436+
Before:
437+
```yaml
438+
framework:
439+
workflows:
440+
article:
441+
type: workflow
442+
marking_store:
443+
type: single_state
444+
```
445+
446+
After:
447+
```yaml
448+
framework:
449+
workflows:
450+
article:
451+
type: state_machine
452+
```
393453

394454
Yaml
395455
----

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+34-4Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
233233
$workflows = [];
234234
}
235235

236-
if (1 === \count($workflows) && isset($workflows['workflows']) && array_keys($workflows['workflows']) !== range(0, \count($workflows) - 1) && !empty(array_diff(array_keys($workflows['workflows']), ['audit_trail', 'type', 'marking_store', 'supports', 'support_strategy', 'initial_places', 'places', 'transitions']))) {
236+
if (1 === \count($workflows) && isset($workflows['workflows']) && array_keys($workflows['workflows']) !== range(0, \count($workflows) - 1) && !empty(array_diff(array_keys($workflows['workflows']), ['audit_trail', 'type', 'marking_store', 'supports', 'support_strategy', 'initial_marking', 'places', 'transitions']))) {
237237
$workflows = $workflows['workflows'];
238238
}
239239

@@ -258,9 +258,17 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
258258
->arrayNode('workflows')
259259
->useAttributeAsKey('name')
260260
->prototype('array')
261+
->beforeNormalization()
262+
->always(function ($v) {
263+
if (isset($v['initial_place'])) {
264+
$v['initial_marking'] = [$v['initial_place']];
265+
}
266+
267+
return $v;
268+
})
269+
->end()
261270
->fixXmlConfig('support')
262271
->fixXmlConfig('place')
263-
->fixXmlConfig('initial_place')
264272
->fixXmlConfig('transition')
265273
->children()
266274
->arrayNode('audit_trail')
@@ -275,8 +283,17 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
275283
->children()
276284
->enumNode('type')
277285
->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()
278294
->end()
279295
->arrayNode('arguments')
296+
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3. Use "property" instead.')
280297
->beforeNormalization()
281298
->ifString()
282299
->then(function ($v) { return [$v]; })
@@ -285,6 +302,9 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
285302
->prototype('scalar')
286303
->end()
287304
->end()
305+
->scalarNode('property')
306+
->defaultValue('marking')
307+
->end()
288308
->scalarNode('service')
289309
->cannotBeEmpty()
290310
->end()
@@ -315,10 +335,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
315335
->cannotBeEmpty()
316336
->end()
317337
->scalarNode('initial_place')
318-
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3, use the "initial_places" configuration key instead.')
338+
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3, use the "initial_marking" configuration key instead.')
319339
->defaultNull()
320340
->end()
321-
->arrayNode('initial_places')
341+
->arrayNode('initial_marking')
322342
->beforeNormalization()
323343
->ifTrue(function ($v) { return !\is_array($v); })
324344
->then(function ($v) { return [$v]; })
@@ -454,6 +474,16 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
454474
})
455475
->thenInvalid('"supports" or "support_strategy" should be configured.')
456476
->end()
477+
->validate()
478+
->ifTrue(function ($v) {
479+
return 'workflow' === $v['type'] && 'single_state' === ($v['marking_store']['type'] ?? false);
480+
})
481+
->then(function ($v) {
482+
@trigger_error('Using a workflow with type=workflow and a marking_store=single_state is deprecated since Symfony 4.3. Use type=state_machine instead.', E_USER_DEPRECATED);
483+
484+
return $v;
485+
})
486+
->end()
457487
->end()
458488
->end()
459489
->end()

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+13-9Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -631,21 +631,28 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
631631

632632
// Create places
633633
$places = array_column($workflow['places'], 'name');
634-
$initialPlaces = $workflow['initial_places'] ?? $workflow['initial_place'] ?? [];
634+
$initialMarking = $workflow['initial_marking'] ?? $workflow['initial_place'] ?? [];
635635

636636
// Create a Definition
637637
$definitionDefinition = new Definition(Workflow\Definition::class);
638638
$definitionDefinition->setPublic(false);
639639
$definitionDefinition->addArgument($places);
640640
$definitionDefinition->addArgument($transitions);
641-
$definitionDefinition->addArgument($initialPlaces);
641+
$definitionDefinition->addArgument($initialMarking);
642642
$definitionDefinition->addArgument($metadataStoreDefinition);
643643

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);
647+
if ('method' === $workflow['marking_store']['type']) {
648+
$markingStoreDefinition->setArguments([
649+
'state_machine' === $type, //single state
650+
$workflow['marking_store']['property'],
651+
]);
652+
} else {
653+
foreach ($workflow['marking_store']['arguments'] as $argument) {
654+
$markingStoreDefinition->addArgument($argument);
655+
}
649656
}
650657
} elseif (isset($workflow['marking_store']['service'])) {
651658
$markingStoreDefinition = new Reference($workflow['marking_store']['service']);
@@ -670,23 +677,20 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
670677
case 'state_machine' === $workflow['type']:
671678
$validator = new Workflow\Validator\StateMachineValidator();
672679
break;
673-
case 'method' === ($workflow['marking_store']['type'] ?? null):
674-
$singlePlace = $workflow['marking_store']['arguments'][0] ?? false;
675-
$validator = new Workflow\Validator\WorkflowValidator($singlePlace);
676-
break;
677680
case 'single_state' === ($workflow['marking_store']['type'] ?? null):
678681
$validator = new Workflow\Validator\WorkflowValidator(true);
679682
break;
680683
case 'multiple_state' === ($workflow['marking_store']['type'] ?? false):
681684
$validator = new Workflow\Validator\WorkflowValidator(false);
682685
break;
683686
}
687+
684688
if ($validator) {
685689
$realDefinition = (new Workflow\DefinitionBuilder($places))
686690
->addTransitions(array_map(function (Reference $ref) use ($container): Workflow\Transition {
687691
return $container->get((string) $ref);
688692
}, $transitions))
689-
->setInitialPlace($initialPlaces)
693+
->setInitialPlace($initialMarking)
690694
->build()
691695
;
692696
$validator->validate($realDefinition, $name);

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@
279279

280280
<xsd:complexType name="workflow">
281281
<xsd:sequence>
282-
<xsd:element name="initial-place" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
282+
<xsd:element name="initial-marking" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
283283
<xsd:element name="marking-store" type="marking_store" minOccurs="0" maxOccurs="1" />
284284
<xsd:element name="support" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
285285
<xsd:element name="place" type="place" minOccurs="0" maxOccurs="unbounded" />
@@ -289,6 +289,7 @@
289289
<xsd:attribute name="name" type="xsd:string" />
290290
<xsd:attribute name="type" type="workflow_type" />
291291
<xsd:attribute name="initial-place" type="xsd:string" />
292+
<xsd:attribute name="initial-marking" type="xsd:string" />
292293
<xsd:attribute name="support-strategy" type="xsd:string" />
293294
<xsd:attribute name="enabled" type="xsd:boolean" />
294295
</xsd:complexType>
@@ -304,12 +305,14 @@
304305
</xsd:sequence>
305306
<xsd:attribute name="type" type="marking_store_type" />
306307
<xsd:attribute name="service" type="xsd:string" />
308+
<xsd:attribute name="property" type="xsd:string" />
307309
</xsd:complexType>
308310

309311
<xsd:simpleType name="marking_store_type">
310312
<xsd:restriction base="xsd:string">
311313
<xsd:enumeration value="multiple_state" />
312314
<xsd:enumeration value="single_state" />
315+
<xsd:enumeration value="method" />
313316
</xsd:restriction>
314317
</xsd:simpleType>
315318

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow-legacy.php
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
<?php
22

3-
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
4-
53
$container->loadFromExtension('framework', [
64
'workflows' => [
75
'legacy' => [
8-
'type' => 'workflow',
6+
'type' => 'state_machine',
7+
'marking_store' => [
8+
'type' => 'single_state',
9+
'arguments' => [
10+
'state',
11+
],
12+
],
913
'supports' => [
1014
stdClass::class,
1115
],
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'workflows' => [
77
'my_workflow' => [
88
'marking_store' => [
9-
'type' => 'multiple_state',
9+
'type' => 'method',
1010
'service' => 'workflow_service',
1111
],
1212
'supports' => [

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
'workflows' => [
77
'article' => [
88
'type' => 'workflow',
9-
'marking_store' => [
10-
'type' => 'multiple_state',
11-
],
129
'supports' => [
1310
FrameworkExtensionTest::class,
1411
],
15-
'initial_places' => ['draft'],
12+
'initial_marking' => ['draft'],
1613
'places' => [
1714
'draft',
1815
'wait_for_journalist',

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
'workflows' => [
77
'article' => [
88
'type' => 'workflow',
9-
'marking_store' => [
10-
'type' => 'multiple_state',
11-
],
129
'supports' => [
1310
FrameworkExtensionTest::class,
1411
],
15-
'initial_places' => ['draft'],
12+
'initial_marking' => ['draft'],
1613
'places' => [
1714
'draft',
1815
'wait_for_journalist',

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.