8000 feature #22771 [Workflow] Removed deprecated features (lyrixx) · symfony/symfony@a91a7de · GitHub
[go: up one dir, main page]

Skip to content

Commit a91a7de

Browse files
committed
feature #22771 [Workflow] Removed deprecated features (lyrixx)
This PR was squashed before being merged into the 4.0-dev branch (closes #22771). Discussion ---------- [Workflow] Removed deprecated features | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a --- Note: all commits are atomic Commits ------- 3bed8f6 [Workflow] The `type` option of the `framework.workflows.*` configuration entries is `state_machine` fd25777 [Workflow] Removed FrameworkBundle/DependencyInjection/Compiler/ValidateWorkflowsPass 1ccbe0b [Workflow] Removed class name support in `WorkflowRegistry::add()` as second parameter
2 parents 31f74ca + 3bed8f6 commit a91a7de

File tree

14 files changed

+24
-130
lines changed

14 files changed

+24
-130
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
4.0.0
5+
-----
6+
7+
* Removed `ValidateWorkflowsPass`
8+
* The default `type` option of the `framework.workflows.*` configuration entries is `state_machine`
9+
410
3.3.0
511
-----
612

@@ -47,7 +53,7 @@ CHANGELOG
4753
`Symfony\Component\Validator\DependencyInjection\AddValidatorInitializersPass` instead
4854
* Deprecated `AddConstraintValidatorsPass`, use
4955
`Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass` instead
50-
* Deprecated `ValidateWorkflowsPass`, use
56+
* Deprecated `ValidateWorkflowsPass`, use
5157
`Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass` instead
5258

5359
3.2.0

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ValidateWorkflowsPass.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
230230
->end()
231231
->enumNode('type')
232232
->values(array('workflow', 'state_machine'))
233+
->defaultValue('state_machine')
233234
->end()
234235
->arrayNode('marking_store')
235236
->fixXmlConfig('argument')

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,6 @@ private function registerWorkflowConfiguration(array $workflows, ContainerBuilde
498498
$registryDefinition = $container->getDefinition('workflow.registry');
499499

500500
foreach ($workflows as $name => $workflow) {
501-
if (!array_key_exists('type', $workflow)) {
502-
$workflow['type'] = 'workflow';
503-
@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);
504-
}
505501
$type = $workflow['type'];
506502

507503
$transitions = array();

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
),
4242
),
4343
'pull_request' => array(
44-
'type' => 'state_machine',
4544
'marking_store' => array(
4645
'type' => 'single_state',
4746
),

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_without_type.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</framework:transition>
4040
</framework:workflow>
4141

42-
<framework:workflow name="pull_request" type="state_machine" initial-place="start">
42+
<framework:workflow name="pull_request" initial-place="start">
4343
<framework:marking-store type="single_state"/>
4444
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
4545
<framework:place>start</framework:place>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_without_type.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ framework:
2828
from: [approved_by_journalist, approved_by_spellchecker]
2929
to: [published]
3030
pull_request:
31-
type: state_machine
3231
marking_store:
3332
type: single_state
3433
supports:

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_without_type.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ public function testWorkflows()
154154
{
155155
$container = $this->createContainerFromFile('workflows');
156156

157-
$this->assertTrue($container->hasDefinition('workflow.article', 'Workflow is registered as a service'));
158-
$this->assertTrue($container->hasDefinition('workflow.article.definition', 'Workflow definition is registered as a service'));
157+
$this->assertTrue($container->hasDefinition('workflow.article'), 'Workflow is registered as a service');
158+
$this->assertSame('workflow.abstract', $container->getDefinition('workflow.article')->getParent());
159+
$this->assertTrue($container->hasDefinition('workflow.article.definition'), 'Workflow definition is registered as a service');
159160

160161
$workflowDefinition = $container->getDefinition('workflow.article.definition');
161162

@@ -173,8 +174,9 @@ public function testWorkflows()
173174
);
174175
$this->assertSame(array('workflow.definition' => array(array('name' => 'article', 'type' => 'workflow', 'marking_store' => 'multiple_state'))), $workflowDefinition->getTags());
175176

176-
$this->assertTrue($container->hasDefinition('state_machine.pull_request', 'State machine is registered as a service'));
177-
$this->assertTrue($container->hasDefinition('state_machine.pull_request.definition', 'State machine definition is registered as a service'));
177+
$this->assertTrue($container->hasDefinition('state_machine.pull_request'), 'State machine is registered as a service');
178+
$this->assertSame('state_machine.abstract', $container->getDefinition('state_machine.pull_request')->getParent());
179+
$this->assertTrue($container->hasDefinition('state_machine.pull_request.definition'), 'State machine definition is registered as a service');
178180
$this->assertCount(4, $workflowDefinition->getArgument(1));
179181
$this->assertSame('draft', $workflowDefinition->getArgument(2));
180182

@@ -207,15 +209,6 @@ public function testWorkflows()
207209
$this->assertGreaterThan(0, count($registryDefinition->getMethodCalls()));
208210
}
209211

210-
/**
211-
* @group legacy
212-
* @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.
213-
*/
214-
public function testDeprecatedWorkflowMissingType()
215-
{
216-
$container = $this->createContainerFromFile('workflows_without_type');
217-
}
218-
219212
/**
220213
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
221214
* @expectedExceptionMessage "type" and "service" cannot be used together.

src/Symfony/Component/Workflow/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.0.0
5+
-----
6+
7+
* Removed class name support in `WorkflowRegistry::add()` as second parameter.
8+
49
3.3.0
510
-----
611

src/Symfony/Component/Workflow/Registry.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Workflow;
1313

1414
use Symfony\Component\Workflow\Exception\InvalidArgumentException;
15-
use Symfony\Component\Workflow\SupportStrategy\ClassInstanceSupportStrategy;
1615
use Symfony\Component\Workflow\SupportStrategy\SupportStrategyInterface;
1716

1817
/**
@@ -24,15 +23,13 @@ class Registry
2423
private $workflows = array();
2524

2625
/**
27-
* @param Workflow $workflow
28-
* @param string|SupportStrategyInterface $supportStrategy
26+
* @param Workflow $workflow
27+
* @param SupportStrategyInterface $supportStrategy
2928
*/
3029
public function add(Workflow $workflow, $supportStrategy)
3130
{
3231
if (!$supportStrategy instanceof SupportStrategyInterface) {
33-
@trigger_error('Support of class name string was deprecated after version 3.2 and won\'t work anymore in 4.0.', E_USER_DEPRECATED);
34-
35-
$supportStrategy = new ClassInstanceSupportStrategy($supportStrategy);
32+
throw new \InvalidArgumentException('The "supportStrategy" is not an instance of SupportStrategyInterface.');
3633
}
3734

3835
$this->workflows[] = array($workflow, $supportStrategy);
@@ -64,7 +61,7 @@ public function get($subject, $workflowName = null)
6461
return $matched;
6562
}
6663

67-
private function supports(Workflow $workflow, $supportStrategy, $subject, $workflowName)
64+
private function supports(Workflow $workflow, SupportStrategyInterface $supportStrategy, $subject, $workflowName)
6865
{
6966
if (null !== $workflowName && $workflowName !== $workflow->getName()) {
7067
return false;
< 179B /div>

src/Symfony/Component/Workflow/Tests/RegistryTest.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,6 @@ public function testGetWithNoMatch()
6565
$this->assertSame('workflow1', $w1->getName());
6666
}
6767

68-
/**
69-
* @group legacy
70-
*/
71-
public function testGetWithSuccessLegacyStrategy()
72-
{
73-
$registry = new Registry();
74-
75-
$registry->add(new Workflow(new Definition(array(), array()), $this->getMockBuilder(MarkingStoreInterface::class)->getMock(), $this->getMockBuilder(EventDispatcherInterface::class)->getMock(), 'workflow1'), Subject1::class);
76-
$registry->add(new Workflow(new Definition(array(), array()), $this->getMockBuilder(MarkingStoreInterface::class)->getMock(), $this->getMockBuilder(EventDispatcherInterface::class)->getMock(), 'workflow2'), Subject2::class);
77-
78-
$workflow = $registry->get(new Subject1());
79-
$this->assertInstanceOf(Workflow::class, $workflow);
80-
$this->assertSame('workflow1', $workflow->getName());
81-
82-
$workflow = $registry->get(new Subject1(), 'workflow1');
83-
$this->assertInstanceOf(Workflow::class, $workflow);
84-
$this->assertSame('workflow1', $workflow->getName());
85-
86-
$workflow = $registry->get(new Subject2(), 'workflow2');
87-
$this->assertInstanceOf(Workflow::class, $workflow);
88-
$this->assertSame('workflow2', $workflow->getName());
89-
}
90-
9168
private function createSupportStrategy($supportedClassName)
9269
{
9370
$strategy = $this->getMockBuilder(SupportStrategyInterface::class)->getMock();

0 commit comments

Comments
 (0)
0