File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 13
13
14
14
namespace ApiPlatform \Symfony \Messenger ;
15
15
16
+ use Symfony \Component \HttpFoundation \Request ;
16
17
use Symfony \Component \Messenger \Stamp \StampInterface ;
17
18
18
19
/**
22
23
*/
23
24
final class ContextStamp implements StampInterface
24
25
{
25
- public function __construct (private readonly array $ context = [])
26
+ private readonly array $ context ;
27
+
28
+ public function __construct (array $ context = [])
26
29
{
30
+ if (($ request = ($ context ['request ' ] ?? null )) && $ request instanceof Request && $ request ->hasSession ()) {
31
+ unset($ context ['request ' ]);
32
+ }
33
+
34
+ $ this ->context = $ context ;
27
35
}
28
36
29
37
/**
Original file line number Diff line number Diff line change 15
15
16
16
use ApiPlatform \Symfony \Messenger \ContextStamp ;
17
17
use PHPUnit \Framework \TestCase ;
18
+ use Symfony \Component \HttpFoundation \Request ;
18
19
use Symfony \Component \Messenger \Stamp \StampInterface ;
19
20
20
21
/**
@@ -32,4 +33,16 @@ public function testGetContext(): void
32
33
$ contextStamp = new ContextStamp ();
33
34
$ this ->assertIsArray ($ contextStamp ->getContext ());
34
35
}
36
+
37
+ /**
38
+ * @doesNotPerformAssertions
39
+ */
40
+ public function testSerializable (): void
41
+ {
42
+ $ request = new Request ();
43
+ $ request ->setSessionFactory (function (): void {}); // @phpstan-ignore-line
44
+
45
+ $ stamp = new ContextStamp (['request ' => $ request ]);
46
+ serialize ($ stamp );
47
+ }
35
48
}
You can’t perform that action at this time.
0 commit comments