Skip to content

Commit 4cf48b4

Browse files
committed
returns
1 parent c2adbd0 commit 4cf48b4

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/LiveComponent/src/EventListener/LiveUrlSubscriber.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ public function onKernelResponse(ResponseEvent $event): void
4141
return;
4242
}
4343

44-
$newUrl = null;
45-
if ($previousLocation = $request->headers->get(self::URL_HEADER)) {
46-
$liveProps = $this->getLivePropsToMap($request);
47-
$newUrl = $this->urlFactory->createFromPreviousAndProps($previousLocation, $liveProps['path'], $liveProps['query']);
44+
$newLiveUrl = null;
45+
if ($previousLiveUrl = $request->headers->get(self::URL_HEADER)) {
46+
$liveProps = $this->getLivePropsFromRequest($request);
47+
$newLiveUrl = $this->urlFactory->createFromPreviousAndProps($previousLiveUrl, $liveProps['path'], $liveProps['query']);
4848
}
4949

50-
if ($newUrl) {
51-
$event->getResponse()->headers->set(self::URL_HEADER, $newUrl);
50+
if ($newLiveUrl) {
51+
$event->getResponse()->headers->set(self::URL_HEADER, $newLiveUrl);
5252
}
5353
}
5454

@@ -59,7 +59,13 @@ public static function getSubscribedEvents(): array
5959
];
6060
}
6161

62-
private function getLivePropsToMap(Request $request): array
62+
/**
63+
* @return array{
64+
* path: array<string, mixed>,
65+
* query: array<string, mixed>
66+
* }
67+
*/
68+
private function getLivePropsFromRequest(Request $request): array
6369
{
6470
$componentName = $request->attributes->get('_live_component');
6571
$metadata = $this->metadataFactory->getMetadata($componentName);

0 commit comments

Comments
 (0)