8000 [Workflow] Deprecate worflow and single state marking · symfony/symfony@0393535 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0393535

Browse files
committed
[Workflow] Deprecate worflow and single state marking
1 parent 87839cf commit 0393535

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

UPGRADE-4.3.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,29 @@ Workflow
237237
property: state
238238
```
239239

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
250+
```
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+
240263
Yaml
241264
----
242265

UPGRADE-5.0.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,27 @@ Workflow
430430
property: state
431431
```
432432

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+
```
453+
433454
Yaml
434455
----
435456

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,16 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
474474
})
475475
->thenInvalid('"supports" or "support_strategy" should be configured.')
476476
->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()
477487
->end()
478488
->end()
479489
->end()

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,40 @@ public function testWorkflowValidationStateMachine()
8888
});
8989
}
9090

91+
/**
92+
* @group legacy
93+
* @expectedDeprecation Using a workflow with type=workflow and a marking_store=single_state is deprecated since Symfony 4.3. Use type=state_machine instead.
94+
*/
95+
public function testWorkflowDeprecateWorkflowSingleState()
96+
{
97+
$this->createContainerFromClosure(function ($container) {
98+
$container->loadFromExtension('framework', [
99+
'workflows' => [
100+
'article' => [
101+
'type' => 'workflow',
102+
'marking_store' => [
103+
'type' => 'single_state',
104+
],
105+
'supports' => [
106+
__CLASS__,
107+
],
108+
'places' => [
109+
'a',
110+
'b',
111+
'c',
112+
],
113+
'transitions' => [
114+
'a_to_b' => [
115+
'from' => ['a'],
116+
'to' => ['b'],
117+
],
118+
],
119+
],
120+
],
121+
]);
122+
});
123+
}
124+
91125
/**
92126
* @group legacy
93127
*/

0 commit comments

Comments
 (0)
0