Skip to content

Commit d8d2e65

Browse files
committed
returns
1 parent c2adbd0 commit d8d2e65

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/LiveComponent/src/EventListener/LiveUrlSubscriber.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,20 @@ public function onKernelResponse(ResponseEvent $event): void
3636
if (!$event->isMainRequest()) {
3737
return;
3838
}
39+
3940
$request = $event->getRequest();
4041
if (!$request->attributes->has('_live_component')) {
4142
return;
4243
}
4344

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']);
45+
$newLiveUrl = null;
46+
if ($previousLiveUrl = $request->headers->get(self::URL_HEADER)) {
47+
$liveProps = $this->getLivePropsFromRequest($request);
48+
$newLiveUrl = $this->urlFactory->createFromPreviousAndProps($previousLiveUrl, $liveProps['path'], $liveProps['query']);
4849
}
4950

50-
if ($newUrl) {
51-
$event->getResponse()->headers->set(self::URL_HEADER, $newUrl);
51+
if ($newLiveUrl) {
52+
$event->getResponse()->headers->set(self::URL_HEADER, $newLiveUrl);
5253
}
5354
}
5455

@@ -59,7 +60,13 @@ public static function getSubscribedEvents(): array
5960
];
6061
}
6162

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

0 commit comments

Comments
 (0)