Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/Controller/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@

namespace App\Controller;

use App\Controller\User\ProfileController;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

class HomeController extends AbstractController
{
#[Route('/', name: 'home')]
public function __invoke(): Response
{
return $this->redirectToRoute('user_profile');
/** The empty _locale default makes this page also work without the _locale prefix. */
#[Route('/', name: 'home', defaults: ['_locale' => ''])]
public function __invoke(
Request $request,
#[Autowire('%locales%')] array $locales,
#[Autowire('%locale%')] string $locale,
): Response {
return $this->redirectToRoute('user_profile', [
'_locale' => $request->getPreferredLanguage($locales) ?? $locale
]);
}
}