-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle][Workflow] Deprecate the default type of a workflow #22416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -440,6 +440,10 @@ private function registerWorkflowConfiguration(array $workflows, ContainerBuilde | |
$registryDefinition = $container->getDefinition('workflow.registry'); | ||
|
||
foreach ($workflows as $name => $workflow) { | ||
if (!array_key_exists('type', $workflow)) { | ||
$workflow['type'] = 'workflow'; | ||
@trigger_error(sprintf('The "type" option of the "framework.workflows.%s" configuration entry must be defined since Symfony 3.3. The default value will be "state_machine" in Symfony 4.0.', $name), E_USER_DEPRECATED); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. much better would be to put it in the
This would keep the deprecation warning in the same place than the new way of doing things in Symfony 4, making it easier to update the code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and we should have a legacy test covering the case of the default to ensure it does not break in 3.x There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In symfony 4, The default value will be "state_machine". So the isRequired will not be needed, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to use the validate way, but the DX is worst as I'm not able to attache the workflow name in the deprecation message. For recall, the workflow name is the key of the prototype. So I prefer this way. More over, there are more code and finally the argument "making it easier to update the code" is not really an issue, since I (I guess) will update the code for SF 4.0 |
||
} | ||
$type = $workflow['type']; | ||
|
||
$transitions = array(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; | ||
|
||
$container->loadFromExtension('framework', array( | ||
'workflows' => array( | ||
'missing_type' => array( | ||
'marking_store' => array( | ||
'service' => 'workflow_service', | ||
), | ||
'supports' => array( | ||
\stdClass::class, | ||
), | ||
'places' => array( | ||
'first', | ||
'last', | ||
), | ||
'transitions' => array( | ||
'go' => array( | ||
'from' => 'first', | ||
'to' => 'last', | ||
), | ||
), | ||
), | ||
), | ||
)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:framework="http://symfony.com/schema/dic/symfony" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | ||
|
||
<framework:config> | ||
<framework:workflow name="missing_type"> | ||
<framework:marking-store service="workflow_service"/> | ||
<framework:support>stdClass</framework:support> | ||
<framework:place>first</framework:place> | ||
<framework:place>last</framework:place> | ||
<framework:transition name="go"> | ||
<framework:from>first</framework:from> | ||
<framework:to>last</framework:to> | ||
</framework:transition> | ||
</framework:workflow> | ||
</framework:config> | ||
</container> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
framework: | ||
workflows: | ||
missing_type: | ||
supports: stdClass | ||
places: [ first, second ] | ||
transitions: | ||
go: {from: first, to: last } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
isset()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. It's a matter of personal style here, isn't ?