diff --git a/UPGRADE-4.3.md b/UPGRADE-4.3.md index aeb2b1181f..020f3a4018 100644 --- a/UPGRADE-4.3.md +++ b/UPGRADE-4.3.md @@ -237,6 +237,29 @@ Workflow property: state ``` + * Using a workflow with a single state marking is deprecated. Use a state machine instead. + + Before: + ```yaml + framework: + workflows: + article: + type: workflow + marking_store: + type: single_state + ``` + + After: + ```yaml + framework: + workflows: + article: + type: state_machine + marking_store: + # type: single_state # Since the single_state marking store is deprecated, use method instead + type: method + ``` + Yaml ---- diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 70bfdf3542..68001974bb 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -430,6 +430,27 @@ Workflow property: state ``` + + * Support for using a workflow with a single state marking is dropped. Use a state machine instead. + + Before: + ```yaml + framework: + workflows: + article: + type: workflow + marking_store: + type: single_state + ``` + + After: + ```yaml + framework: + workflows: + article: + type: state_machine + ``` + Yaml ---- diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index a398054c5f..f50c951a3e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -474,6 +474,16 @@ class Configuration implements ConfigurationInterface }) ->thenInvalid('"supports" or "support_strategy" should be configured.') ->end() + ->validate() + ->ifTrue(function ($v) { + return 'workflow' === $v['type'] && 'single_state' === ($v['marking_store']['type'] ?? false); + }) + ->then(function ($v) { + @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); + + return $v; + }) + ->end() ->end() ->end() ->end() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php index 259ada2f39..a67a358447 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php @@ -88,6 +88,40 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest }); } + /** + * @group legacy + * @expectedDeprecation Using a workflow with type=workflow and a marking_store=single_state is deprecated since Symfony 4.3. Use type=state_machine instead. + */ + public function testWorkflowDeprecateWorkflowSingleState() + { + $this->createContainerFromClosure(function ($container) { + $container->loadFromExtension('framework', [ + 'workflows' => [ + 'article' => [ + 'type' => 'workflow', + 'marking_store' => [ + 'type' => 'single_state', + ], + 'supports' => [ + __CLASS__, + ], + 'places' => [ + 'a', + 'b', + 'c', + ], + 'transitions' => [ + 'a_to_b' => [ + 'from' => ['a'], + 'to' => ['b'], + ], + ], + ], + ], + ]); + }); + } + /** * @group legacy */