[FrameworkBundle][Workflow] Deprecate the default type of a workflow
Before this patch, the default type is "workflow". Most of the time a "state_machine" is better because it's simpler and it involves less knowledge to be able to use it. So this patch deprecate a missing type in Symfony 3.3. And In Symfony 4.0 the default value will become "state_machine".
This commit is contained in:
parent
46fc0b9363
commit
004751c5e8
@ -168,6 +168,9 @@ FrameworkBundle
|
|||||||
|
|
||||||
* The "framework.trusted_proxies" configuration option and the corresponding "kernel.trusted_proxies" parameter have been deprecated and will be removed in 4.0. Use the Request::setTrustedProxies() method in your front controller instead.
|
* The "framework.trusted_proxies" configuration option and the corresponding "kernel.trusted_proxies" parameter have been deprecated and will be removed in 4.0. Use the Request::setTrustedProxies() method in your front controller instead.
|
||||||
|
|
||||||
|
* Not defining the `type` option of the `framework.workflows.*` configuration entries is deprecated.
|
||||||
|
The default value will be `state_machine` in Symfony 4.0.
|
||||||
|
|
||||||
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDumpPass` has been deprecated.
|
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDumpPass` has been deprecated.
|
||||||
|
|
||||||
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass` has been deprecated.
|
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass` has been deprecated.
|
||||||
|
@ -228,6 +228,8 @@ FrameworkBundle
|
|||||||
|
|
||||||
* The "framework.trusted_proxies" configuration option and the corresponding "kernel.trusted_proxies" parameter have been removed. Use the `Request::setTrustedProxies()` method in your front controller instead.
|
* The "framework.trusted_proxies" configuration option and the corresponding "kernel.trusted_proxies" parameter have been removed. Use the `Request::setTrustedProxies()` method in your front controller instead.
|
||||||
|
|
||||||
|
* The default value of the `framework.workflows.[name].type` configuration options is now `state_machine`.
|
||||||
|
|
||||||
* Support for absolute template paths has been removed.
|
* Support for absolute template paths has been removed.
|
||||||
|
|
||||||
* The following form types registered as services have been removed; use their
|
* The following form types registered as services have been removed; use their
|
||||||
|
@ -4,6 +4,8 @@ CHANGELOG
|
|||||||
3.3.0
|
3.3.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
* Not defining the `type` option of the `framework.workflows.*` configuration entries is deprecated.
|
||||||
|
The default value will be `state_machine` in Symfony 4.0.
|
||||||
* Deprecated the `CompilerDebugDumpPass` class
|
* Deprecated the `CompilerDebugDumpPass` class
|
||||||
* [BC BREAK] Removed the "framework.trusted_proxies" configuration option and the corresponding "kernel.trusted_proxies" parameter
|
* [BC BREAK] Removed the "framework.trusted_proxies" configuration option and the corresponding "kernel.trusted_proxies" parameter
|
||||||
* Added a new new version strategy option called json_manifest_path
|
* Added a new new version strategy option called json_manifest_path
|
||||||
|
@ -230,7 +230,6 @@ class Configuration implements ConfigurationInterface
|
|||||||
->end()
|
->end()
|
||||||
->enumNode('type')
|
->enumNode('type')
|
||||||
->values(array('workflow', 'state_machine'))
|
->values(array('workflow', 'state_machine'))
|
||||||
->defaultValue('workflow')
|
|
||||||
->end()
|
->end()
|
||||||
->arrayNode('marking_store')
|
->arrayNode('marking_store')
|
||||||
->fixXmlConfig('argument')
|
->fixXmlConfig('argument')
|
||||||
|
@ -440,6 +440,10 @@ class FrameworkExtension extends Extension
|
|||||||
$registryDefinition = $container->getDefinition('workflow.registry');
|
$registryDefinition = $container->getDefinition('workflow.registry');
|
||||||
|
|
||||||
foreach ($workflows as $name => $workflow) {
|
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);
|
||||||
|
}
|
||||||
$type = $workflow['type'];
|
$type = $workflow['type'];
|
||||||
|
|
||||||
$transitions = array();
|
$transitions = array();
|
||||||
|
@ -89,6 +89,7 @@ $container->loadFromExtension('framework', array(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
'service_marking_store_workflow' => array(
|
'service_marking_store_workflow' => array(
|
||||||
|
'type' => 'workflow',
|
||||||
'marking_store' => array(
|
'marking_store' => array(
|
||||||
'service' => 'workflow_service',
|
'service' => 'workflow_service',
|
||||||
),
|
),
|
||||||
|
@ -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',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
@ -80,7 +80,7 @@
|
|||||||
</framework:transition>
|
</framework:transition>
|
||||||
</framework:workflow>
|
</framework:workflow>
|
||||||
|
|
||||||
<framework:workflow name="service_marking_store_workflow">
|
<framework:workflow name="service_marking_store_workflow" type="workflow">
|
||||||
<framework:marking-store service="workflow_service"/>
|
<framework:marking-store service="workflow_service"/>
|
||||||
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
|
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
|
||||||
<framework:place>first</framework:place>
|
<framework:place>first</framework:place>
|
||||||
|
@ -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>
|
@ -64,6 +64,7 @@ framework:
|
|||||||
from: closed
|
from: closed
|
||||||
to: review
|
to: review
|
||||||
service_marking_store_workflow:
|
service_marking_store_workflow:
|
||||||
|
type: workflow
|
||||||
marking_store:
|
marking_store:
|
||||||
service: workflow_service
|
service: workflow_service
|
||||||
supports:
|
supports:
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
framework:
|
||||||
|
workflows:
|
||||||
|
missing_type:
|
||||||
|
supports: stdClass
|
||||||
|
places: [ first, second ]
|
||||||
|
transitions:
|
||||||
|
go: {from: first, to: last }
|
@ -207,6 +207,15 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
$this->assertGreaterThan(0, count($registryDefinition->getMethodCalls()));
|
$this->assertGreaterThan(0, count($registryDefinition->getMethodCalls()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
* @expectedDeprecation The "type" option of the "framework.workflows.missing_type" configuration entry must be defined since Symfony 3.3. The default value will be "state_machine" in Symfony 4.0.
|
||||||
|
*/
|
||||||
|
public function testDeprecatedWorkflowMissingType()
|
||||||
|
{
|
||||||
|
$container = $this->createContainerFromFile('workflows_without_type');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||||
* @expectedExceptionMessage "type" and "service" cannot be used together.
|
* @expectedExceptionMessage "type" and "service" cannot be used together.
|
||||||
|
Reference in New Issue
Block a user