Skip to content

Commit 4788d19

Browse files
committed
[FrameworkBundle][Workflow] Attach the workflow's configuration to the workflow tag
1 parent 72c80dd commit 4788d19

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
* Add native return type to `Translator` and to `Application::reset()`
88
* Deprecate the integration of Doctrine annotations, either uninstall the `doctrine/annotations` package or disable the integration by setting `framework.annotations` to `false`
9+
* Attach the workflow's configuration to the `workflow` tag
910

1011
6.3
1112
---

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

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

1037-
$workflowDefinition->addTag('workflow', ['name' => $name]);
1037+
$workflowDefinition->addTag('workflow', ['name' => $name, 'config' => $workflow]);
10381038
if ('workflow' === $type) {
10391039
$workflowDefinition->addTag('workflow.workflow', ['name' => $name]);
10401040
} elseif ('state_machine' === $type) {

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
4646
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
4747
use Symfony\Component\DependencyInjection\Reference;
48+
use Symfony\Component\DependencyInjection\Tests\Compiler\D;
4849
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
4950
use Symfony\Component\Finder\Finder;
5051
use Symfony\Component\Form\Form;
@@ -305,7 +306,12 @@ public function testWorkflows()
305306
$this->assertArrayHasKey('index_4', $args);
306307
$this->assertNull($args['index_4'], 'Workflows has eventsToDispatch=null');
307308

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

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

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

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

341352
$stateMachineDefinition = $container->getDefinition('state_machine.pull_request.definition');
342353

0 commit comments

Comments
 (0)