Skip to content

Commit 3f8c934

Browse files
authored
Adding note about new way to set the Turbo Stream format
1 parent 5201f54 commit 3f8c934

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sfcasts/turbo/stream-everything.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ for that in the controller.
9191
Here's how it looks: wrap our stream render with if
9292
`TurboStreamResponse::STREAM_FORMAT` equals `$request->getPreferredFormat()`.
9393

94+
***TIP
95+
In symfony/ux-turbo 2.1 and higher, this code has changed:
96+
97+
```php
98+
if (TurboBundle::STREAM_FORMAT === $request->getPreferredFormat()) {
99+
$request->setFormat(TurboBundle::STREAM_FORMAT);
100+
101+
return $this->render('product/reviews.stream.html.twig', [
102+
'product' => $product,
103+
]);
104+
}
105+
```
106+
***
107+
94108
[[[ code('eaa99b1e97') ]]]
95109

96110
That's it. This preferred format thing basically looks at the `Accept` request header

0 commit comments

Comments
 (0)