8000 bug #20760 [FrameworkBundle] [Workflow] Fix service marking store con… · symfony/symfony@af0043b · GitHub
[go: up one dir, main page]

Skip to content

Commit af0043b

Browse files
bug #20760 [FrameworkBundle] [Workflow] Fix service marking store configuration (fduch)
This PR was submitted for the master branch but it was merged into the 3.2 branch instead (closes #20760). Discussion ---------- [FrameworkBundle] [Workflow] Fix service marking store configuration | Q | A | ------------- | --- | Branch? | "master" | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | no | License | MIT | Doc PR | no Currently workflow marking store configuration [checks](https://github.com/symfony/symfony/blob/3.2/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php#L271-L272) that `service` and `arguments` fields are not specified simultaneously using `isset` function. Since [arguments node](https://github.com/symfony/symfony/blob/3.2/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php#L253-L261) defines prototype node inside, even if `arguments` node is not specified, - after processing it looks like empty array. If `service` setting is set it leads to failing build with validation error message (due to `isset([])` returns `true`): `"arguments" and "service" cannot be used together.`. This patch addresses this issue. Commits ------- 3289b10 [FrameworkBundle] [Workflow] Fix service marking store configuration
2 parents a28c522 + 3289b10 commit af0043b

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
268268
->thenInvalid('"type" and "service" cannot be used together.')
269269
->end()
270270
->validate()
271-
->ifTrue(function ($v) { return isset($v['arguments']) && isset($v['service']); })
271+
->ifTrue(function ($v) { return !empty($v['arguments']) && isset($v['service']); })
272272
->thenInvalid('"arguments" and "service" cannot be used together.')
273273
->end()
274274
->end()

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,23 @@
8888
),
8989
),
9090
),
91+
'service_marking_store_workflow' => array(
92+
'marking_store' => array(
93+
'service' => 'workflow_service',
94+
),
95+
10000 'supports' => array(
96+
FrameworkExtensionTest::class,
97+
),
98+
'places' => array(
99+
'first',
100+
'last',
101+
),
102+
'transitions' => array(
103+
'go' => array(
104+
'from' => 'first',
105+
'to' => 'last',
106+
),
107+
),
108+
),
91109
),
92110
));

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,16 @@
7979
<framework:to>review</framework:to>
8080
</framework:transition>
8181
</framework:workflow>
82+
83+
<framework:workflow name="service_marking_store_workflow">
84+
<framework:marking-store service="workflow_service"/>
85+
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
86+
<framework:place>first</framework:place>
87+
<framework:place>last</framework:place>
88+
<framework:transition name="go">
89+
<framework:from>first</framework:from>
90+
<framework:to>last</framework:to>
91+
</framework:transition>
92+
</framework:workflow>
8293
</framework:config>
8394
</container>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,17 @@ framework:
6363
reopen:
6464
from: closed
6565
to: review
66+
service_marking_store_workflow:
67+
marking_store:
68+
service: workflow_service
69+
supports:
70+
- Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
71+
places:
72+
- first
73+
- last
74+
transitions:
75+
go:
76+
from:
77+
- first
78+
to:
79+
- last

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ public function testWorkflows()
165165
$this->assertSame(array('workflow.definition' => array(array('name' => 'pull_request', 'type' => 'state_machine', 'marking_store' => 'single_state'))), $stateMachineDefinition->getTags());
166166
$this->assertCount(9, $stateMachineDefinition->getArgument(1));
167167
$this->assertSame('start', $stateMachineDefinition->getArgument(2));
168+
169+
$serviceMarkingStoreWorkflowDefinition = $container->getDefinition('workflow.service_marking_store_workflow');
170+
/** @var Reference $markingStoreRef */
171+
$markingStoreRef = $serviceMarkingStoreWorkflowDefinition->getArgument(1);
172+
$this->assertInstanceOf(Reference::class, $markingStoreRef);
173+
$this->assertEquals('workflow_service', (string) $markingStoreRef);
168174
}
169175

170176
/**

0 commit comments

Comments
 (0)
0