forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfixredirect-finish-subscriber.diff
32 lines (30 loc) · 1.13 KB
/
fixredirect-finish-subscriber.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
diff --git a/src/EventSubscriber/TurboFrameRedirectSubscriber.php b/src/EventSubscriber/TurboFrameRedirectSubscriber.php
index eee47c6..577ced6 100644
--- a/src/EventSubscriber/TurboFrameRedirectSubscriber.php
+++ b/src/EventSubscriber/TurboFrameRedirectSubscriber.php
@@ -14,6 +14,11 @@ class TurboFrameRedirectSubscriber implements EventSubscriberInterface
if (!$this->shouldWrapRedirect($event->getRequest(), $event->getResponse())) {
return;
}
+
+ $response = new Response(null, 200, [
+ 'Turbo-Location' => $event->getResponse()->headers->get('Location'),
+ ]);
+ $event->setResponse($response);
}
public static function getSubscribedEvents()
@@ -29,14 +34,6 @@ class TurboFrameRedirectSubscriber implements EventSubscriberInterface
return false;
}
- if (!$request->headers->has('Turbo-Frame')) {
- return false;
- }
-
- if ($request->headers->get('Turbo-Frame-Redirect')) {
- return true;
- }
-
- return false;
+ return (bool) $request->headers->get('Turbo-Frame-Redirect');
}
}