Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 682b35f

Browse files
committed
[FrameworkBundle][Workflow] Attach the workflow's configuration to the workflow tag
1 parent 071a971 commit 682b35f

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ CHANGELOG
4242
* Deprecate `DataCollectorTranslatorPass`, use `Symfony\Component\Translation\DependencyInjection\DataCollectorTranslatorPass` instead
4343
* Deprecate `LoggingTranslatorPass`, use `Symfony\Component\Translation\DependencyInjection\LoggingTranslatorPass` instead
4444
* Deprecate `WorkflowGuardListenerPass`, use `Symfony\Component\Workflow\DependencyInjection\WorkflowGuardListenerPass` instead
45+
* Attach the workflow's configuration to the `workflow` tag
4546

4647
6.3
4748
---

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
10411041
$workflowDefinition->replaceArgument(3, $name);
10421042
$workflowDefinition->replaceArgument(4, $workflow['events_to_dispatch']);
10431043

1044-
$workflowDefinition->addTag('workflow', ['name' => $name]);
1044+
$workflowDefinition->addTag('workflow', ['name' => $name, 'config' => $workflow]);
10451045
if ('workflow' === $type) {
10461046
$workflowDefinition->addTag('workflow.workflow', ['name' => $name]);
10471047
} elseif ('state_machine' === $type) {

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,12 @@ public function testWorkflows()
305305
$this->assertArrayHasKey('index_4', $args);
306306
$this->assertNull($args['index_4'], 'Workflows has eventsToDispatch=null');
307307

308-
$this->assertSame(['workflow' => [['name' => 'article']], 'workflow.workflow' => [['name' => 'article']]], $container->getDefinition('workflow.article')->getTags());
308+
$tags = $container->getDefinition('workflow.article')->getTags();
309+
$this->assertArrayHasKey('workflow', $tags);
310+
$this->assertArrayHasKey('workflow.workflow', $tags);
311+
$this->assertSame([['name' => 'article']], $tags['workflow.workflow']);
312+
$this->assertSame('article', $tags['workflow'][0]['name'] ?? null);
313+
$this->assertSame('workflow', $tags['workflow'][0]['config']['type'] ?? null);
309314

310315
$this->assertTrue($container->hasDefinition('workflow.article.definition'), 'Workflow definition is registered as a service');
311316

@@ -336,7 +341,12 @@ public function testWorkflows()
336341
$this->assertSame('state_machine.abstract', $container->getDefinition('state_machine.pull_request')->getParent());
337342
$this->assertTrue($container->hasDefinition('state_machine.pull_request.definition'), 'State machine definition is registered as a service');
338343

339-
$this->assertSame(['workflow' => [['name' => 'pull_request']], 'workflow.state_machine' => [['name' => 'pull_request']]], $container->getDefinition('state_machine.pull_request')->getTags());
344+
$tags = $container->getDefinition('state_machine.pull_request')->getTags();
345+
$this->assertArrayHasKey('workflow', $tags);
346+
$this->assertArrayHasKey('workflow.state_machine', $tags);
347+
$this->assertSame([['name' => 'pull_request']], $tags['workflow.state_machine']);
348+
$this->assertSame('pull_request', $tags['workflow'][0]['name'] ?? null);
349+
$this->assertSame('state_machine', $tags['workflow'][0]['config']['type'] ?? null);
340350

341351
$stateMachineDefinition = $container->getDefinition('state_machine.pull_request.definition');
342352

0 commit comments

Comments
 (0)