|
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,41 @@ 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 | + $currentBaseUrl = $context->getBaseUrl(); |
| 53 | + $currentMethod = $context->getMethod(); |
| 54 | + $currentHost = $context->getHost(); |
| 55 | + $currentScheme = $context->getScheme(); |
| 56 | + $currentHttpPort = $context->getHttpPort(); |
| 57 | + $currentHttpsPort = $context->getHttpsPort(); |
| 58 | + $currentPathInfo = $context->getPathInfo(); |
| 59 | + $currentQueryString = $context->getQueryString(); |
53 | 60 |
|
54 | 61 | /* @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 |
| - )); |
| 62 | + $context |
| 63 | + ->setBaseUrl($contextStamp->getBaseUrl()) |
| 64 | + ->setMethod($contextStamp->getMethod()) |
| 65 | + ->setHost($contextStamp->getHost()) |
| 66 | + ->setScheme($contextStamp->getScheme()) |
| 67 | + ->setHttpPort($contextStamp->getHttpPort()) |
| 68 | + ->setHttpsPort($contextStamp->getHttpsPort()) |
| 69 | + ->setPathInfo($contextStamp->getPathInfo()) |
| 70 | + ->setQueryString($contextStamp->getQueryString()) |
| 71 | + ; |
65 | 72 |
|
66 | 73 | try {
|
67 | 74 | return $stack->next()->handle($envelope, $stack);
|
68 | 75 | } finally {
|
69 |
| - $this->router->setContext($currentContext); |
| 76 | + $context |
| 77 | + ->setBaseUrl($currentBaseUrl) |
| 78 | + ->setMethod($currentMethod) |
| 79 | + ->setHost($currentHost) |
| 80 | + ->setScheme($currentScheme) |
| 81 | + ->setHttpPort($currentHttpPort) |
| 82 | + ->setHttpsPort($currentHttpsPort) |
| 83 | + ->setPathInfo($currentPathInfo) |
| 84 | + ->setQueryString($currentQueryString) |
| 85 | + ; |
70 | 86 | }
|
71 | 87 | }
|
72 | 88 | }
|
0 commit comments