Skip to content

Commit 4d98a70

Browse files
committed
Issue #3082: Add and use ContextStamp.
1 parent e468d98 commit 4d98a70

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\Core\Bridge\Symfony\Messenger;
15+
16+
use Symfony\Component\Messenger\Stamp\StampInterface;
17+
18+
/**
19+
* An envelope stamp with context which related to a message.
20+
*
21+
* @experimental
22+
*
23+
* @author Sergii Pavlenko <[email protected]>
24+
*/
25+
final class ContextStamp implements StampInterface
26+
{
27+
}

src/Bridge/Symfony/Messenger/DataPersister.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ public function supports($data, array $context = []): bool
7575
*/
7676
public function persist($data, array $context = [])
7777
{
78-
$envelope = $this->dispatch($data);
78+
$envelope = $this->dispatch(
79+
(new Envelope($data))
80+
->with(new ContextStamp())
81+
);
7982

8083
$handledStamp = $envelope->last(HandledStamp::class);
8184
if (!$handledStamp instanceof HandledStamp) {

0 commit comments

Comments
 (0)