@@ -36,19 +36,20 @@ public function onKernelResponse(ResponseEvent $event): void
36
36
if (!$ event ->isMainRequest ()) {
37
37
return ;
38
38
}
39
+
39
40
$ request = $ event ->getRequest ();
40
41
if (!$ request ->attributes ->has ('_live_component ' )) {
41
42
return ;
42
43
}
43
44
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 ' ]);
48
49
}
49
50
50
- if ($ newUrl ) {
51
- $ event ->getResponse ()->headers ->set (self ::URL_HEADER , $ newUrl );
51
+ if ($ newLiveUrl ) {
52
+ $ event ->getResponse ()->headers ->set (self ::URL_HEADER , $ newLiveUrl );
52
53
}
53
54
}
54
55
@@ -59,7 +60,13 @@ public static function getSubscribedEvents(): array
59
60
];
60
61
}
61
62
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
63
70
{
64
71
$ componentName = $ request ->attributes ->get ('_live_component ' );
65
72
$ metadata = $ this ->metadataFactory ->getMetadata ($ componentName );
0 commit comments