Skip to content

Commit d997860

Browse files
committed
Issue #3157: Correct passing of context.
1 parent 7bb3d07 commit d997860

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

src/Bridge/Symfony/Messenger/ContextStamp.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,21 @@
2424
*/
2525
final class ContextStamp implements StampInterface
2626
{
27+
/**
28+
* @var array
29+
*/
30+
private $context;
31+
32+
public function __construct($context = [])
33+
{
34+
$this->context = $context;
35+
}
36+
37+
/**
38+
* Get the context related to a message.
39+
*/
40+
public function getContext(): array
41+
{
42+
return $this->context;
43+
}
2744
}

src/Bridge/Symfony/Messenger/DataPersister.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function persist($data, array $context = [])
7777
{
7878
$envelope = $this->dispatch(
7979
(new Envelope($data))
80-
->with(new ContextStamp())
80+
->with(new ContextStamp($context))
8181
);
8282

8383
$handledStamp = $envelope->last(HandledStamp::class);

tests/Bridge/Symfony/Messenger/ContextStampTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the API Platform project.
55
*
6-
* (c) Sergii Pavlenko <sergii.pavlenko.v@gmail.com>
6+
* (c) Kévin Dunglas <dunglas@gmail.com>
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

tests/Bridge/Symfony/Messenger/DataPersisterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
namespace ApiPlatform\Core\Tests\Bridge\Symfony\Messenger;
1515

16+
use ApiPlatform\Core\Bridge\Symfony\Messenger\ContextStamp;
1617
use ApiPlatform\Core\Bridge\Symfony\Messenger\DataPersister;
1718
use ApiPlatform\Core\Bridge\Symfony\Messenger\RemoveStamp;
18-
use ApiPlatform\Core\Bridge\Symfony\Messenger\ContextStamp;
1919
use ApiPlatform\Core\Exception\ResourceClassNotFoundException;
2020
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
2121
use ApiPlatform\Core\Metadata\Resource\ResourceMetadata;

0 commit comments

Comments
 (0)