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

Skip to content

Commit 2fd3770

Browse files
committed
[FrameworkBundle][Workflow] Attach the workflow's configuration to the workflow tag
1 parent 87186b2 commit 2fd3770

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ CHANGELOG
1212
* Add `rate_limiter` tags to rate limiter services
1313
* Add `secrets:reveal` command
1414
* Add `rate_limiter` option to `http_client.default_options` and `http_client.scoped_clients`
15+
* Attach the workflow's configuration to the `workflow` tag
1516

1617
7.0
1718
---

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
10291029
$workflowDefinition->replaceArgument(3, $name);
10301030
$workflowDefinition->replaceArgument(4, $workflow['events_to_dispatch']);
10311031

1032-
$workflowDefinition->addTag('workflow', ['name' => $name]);
1032+
$workflowDefinition->addTag('workflow', ['name' => $name, 'metadata' => $workflow['metadata']]);
10331033
if ('workflow' === $type) {
10341034
$workflowDefinition->addTag('workflow.workflow', ['name' => $name]);
10351035
} elseif ('state_machine' === $type) {

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

+17-2
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,15 @@ public function testWorkflows()
302302
$this->assertArrayHasKey('index_4', $args);
303303
$this->assertNull($args['index_4'], 'Workflows has eventsToDispatch=null');
304304

305-
$this->assertSame(['workflow' => [['name' => 'article']], 'workflow.workflow' => [['name' => 'article']]], $container->getDefinition('workflow.article')->getTags());
305+
$tags = $container->getDefinition('workflow.article')->getTags();
306+
$this->assertArrayHasKey('workflow', $tags);
307+
$this->assertArrayHasKey('workflow.workflow', $tags);
308+
$this->assertSame([['name' => 'article']], $tags['workflow.workflow']);
309+
$this->assertSame('article', $tags['workflow'][0]['name'] ?? null);
310+
$this->assertSame([
311+
'title' => 'article workflow',
312+
'description' => 'workflow for articles',
313+
], $tags['workflow'][0]['metadata'] ?? null);
306314

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

@@ -333,7 +341,14 @@ public function testWorkflows()
333341
$this->assertSame('state_machine.abstract', $container->getDefinition('state_machine.pull_request')->getParent());
334342
$this->assertTrue($container->hasDefinition('state_machine.pull_request.definition'), 'State machine definition is registered as a service');
335343

336-
$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([
350+
'title' => 'workflow title',
351+
], $tags['workflow'][0]['metadata'] ?? null);
337352

338353
$stateMachineDefinition = $container->getDefinition('state_machine.pull_request.definition');
339354

0 commit comments

Comments
 (0)