I'm making a webapp with Symfony 7 and Turbo within.
All of my controllers work well with Turbo, following the simple
#[Route('/{platform}', name: 'app_platform_pick')]
public function platformPick(Request $request, $platform){
$request->setRequestFormat(TurboBundle::STREAM_FORMAT);
return $this->render('platform/'.$platform.'.html.twig');
}
But for the last route of my process, it download on my navigator the file of the Turbo template that is supposed to update on my page. This is the Turbo template I download instead of update on my webpage :
<turbo-stream action="update" target="finalContent">
<template>
<p style="color:white">Playlist created!</p>
</template>
</turbo-stream>
And this is my controller that make me download the file :
#[Route('/authorize/spotify', name: 'app_auth_spotify')]
public function authorizeSpotify(Request $request)
{
if ($request->query->get('code')) {
$accountToken = $this->spotifyService->getUser($request->query->get('code'));
$playlistId = $request->cookies->get('playlistId');
$playlistPlatform = $request->cookies->get('playlistPlatform');
try {
switch ($playlistPlatform) {
case 'spotify':
$this->spotifyService->createPlaylist($accountToken, $playlistId);
break;
case 'deezer':
break;
case 'applemusic':
break;
}
} catch (\Exception $e) {
dd($e);
}
}
$request->setRequestFormat(TurboBundle::STREAM_FORMAT);
return $this->render('main/success.html.twig');
}
I tried to create other routes, but the issue is the same, so I made a redirection to the '/' route and it worked, I guess the issue comes from the Request object because '/' route is the only route with no Request in the parameters like :
#[Route('/', name: 'app_main')]
public function index(): Response
{
return $this->render('main/index.html.twig');
}
Any of you encountered this? Thanks