|
14 | 14 | use Symfony\Component\Messenger\Envelope;
|
15 | 15 | use Symfony\Component\Messenger\Stamp\ConsumedByWorkerStamp;
|
16 | 16 | use Symfony\Component\Messenger\Stamp\RouterContextStamp;
|
17 |
| -use Symfony\Component\Routing\RequestContext; |
18 | 17 | use Symfony\Component\Routing\RequestContextAwareInterface;
|
19 | 18 |
|
20 | 19 | /**
|
@@ -49,24 +48,43 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope
|
49 | 48 | return $stack->next()->handle($envelope, $stack);
|
50 | 49 | }
|
51 | 50 |
|
52 |
| - $currentContext = $this->router->getContext(); |
| 51 | + $context = $this->router->getContext(); |
| 52 | + $currentContext = [ |
| 53 | + $context->getBaseUrl(), |
| 54 | + $context->getMethod(), |
| 55 | + $context->getHost(), |
| 56 | + $context->getScheme(), |
| 57 | + $context->getHttpPort(), |
| 58 | + $context->getHttpsPort(), |
| 59 | + $context->getPathInfo(), |
| 60 | + $context->getQueryString(), |
| 61 | + ]; |
53 | 62 |
|
54 | 63 | /* @var RouterContextStamp $contextStamp */
|
55 |
| - $this->router->setContext(new RequestContext( |
56 |
| - $contextStamp->getBaseUrl(), |
57 |
| - $contextStamp->getMethod(), |
58 |
| - $contextStamp->getHost(), |
59 |
| - $contextStamp->getScheme(), |
60 |
| - $contextStamp->getHttpPort(), |
61 |
| - $contextStamp->getHttpsPort(), |
62 |
| - $contextStamp->getPathInfo(), |
63 |
| - $contextStamp->getQueryString() |
64 |
| - )); |
| 64 | + $context |
| 65 | + ->setBaseUrl($contextStamp->getBaseUrl()) |
| 66 | + ->setMethod($contextStamp->getMethod()) |
| 67 | + ->setHost($contextStamp->getHost()) |
| 68 | + ->setScheme($contextStamp->getScheme()) |
| 69 | + ->setHttpPort($contextStamp->getHttpPort()) |
| 70 | + ->setHttpsPort($contextStamp->getHttpsPort()) |
| 71 | + ->setPathInfo($contextStamp->getPathInfo()) |
| 72 | + ->setQueryString($contextStamp->getQueryString()) |
| 73 | + ; |
65 | 74 |
|
66 | 75 | try {
|
67 | 76 | return $stack->next()->handle($envelope, $stack);
|
68 | 77 | } finally {
|
69 |
| - $this->router->setContext($currentContext); |
| 78 | + $context |
| 79 | + ->setBaseUrl($currentContext[0]) |
| 80 | + ->setMethod($currentContext[1]) |
| 81 | + ->setHost($currentContext[2]) |
| 82 | + ->setScheme($currentContext[3]) |
| 83 | + ->setHttpPort($currentContext[4]) |
| 84 | + ->setHttpsPort($currentContext[5]) |
| 85 | + ->setPathInfo($currentContext[6]) |
| 86 | + ->setQueryString($currentContext[7]) |
| 87 | + ; |
70 | 88 | }
|
71 | 89 | }
|
72 | 90 | }
|
0 commit comments