Skip to content

Commit 75c8463

Browse files
committed
[FrameworkBundle][Workflow] Attach the workflow's configuration to the workflow tag
1 parent f0959b4 commit 75c8463

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
@@ -12,6 +12,7 @@ CHANGELOG
1212
* Add `DomCrawlerAssertionsTrait::assertAnySelectorTextNotContains(string $selector, string $text)`
1313
* Deprecate `EnableLoggerDebugModePass`, use argument `$debug` of HttpKernel's `Logger` instead
1414
* Deprecate `AddDebugLogProcessorPass::configureLogger()`, use HttpKernel's `DebugLoggerConfigurator` instead
15+
* Attach the workflow's configuration to the `workflow` tag
1516

1617
6.3
1718
---

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

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

1038-
$workflowDefinition->addTag('workflow', ['name' => $name]);
1038+
$workflowDefinition->addTag('workflow', ['name' => $name, 'config' => $workflow]);
10391039
if ('workflow' === $type) {
10401040
$workflowDefinition->addTag('workflow.workflow', ['name' => $name]);
10411041
} 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)