[Workflow] Fixed case when the marking store is not defined

This commit is contained in:
Grégoire Pineau 2020-12-01 00:25:57 +01:00
parent 0b8d634706
commit bd38cceaa8
2 changed files with 8 additions and 4 deletions

View File

@ -810,9 +810,7 @@ class FrameworkExtension extends Extension
// Create Workflow
$workflowDefinition = new ChildDefinition(sprintf('%s.abstract', $type));
$workflowDefinition->replaceArgument(0, new Reference(sprintf('%s.definition', $workflowId)));
if (isset($markingStoreDefinition)) {
$workflowDefinition->replaceArgument(1, $markingStoreDefinition);
}
$workflowDefinition->replaceArgument(1, $markingStoreDefinition ?? null);
$workflowDefinition->replaceArgument(3, $name);
$workflowDefinition->replaceArgument(4, $workflow['events_to_dispatch']);

View File

@ -226,7 +226,13 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertTrue($container->hasDefinition('workflow.article'), 'Workflow is registered as a service');
$this->assertSame('workflow.abstract', $container->getDefinition('workflow.article')->getParent());
$this->assertNull($container->getDefinition('workflow.article')->getArgument('index_4'), 'Workflows has eventsToDispatch=null');
$args = $container->getDefinition('workflow.article')->getArguments();
$this->assertArrayHasKey('index_0', $args);
$this->assertArrayHasKey('index_1', $args);
$this->assertArrayHasKey('index_3', $args);
$this->assertArrayHasKey('index_4', $args);
$this->assertNull($args['index_4'], 'Workflows has eventsToDispatch=null');
$this->assertTrue($container->hasDefinition('workflow.article.definition'), 'Workflow definition is registered as a service');