Skip to content
Snippets Groups Projects
Commit 2fae05af authored by user's avatar user
Browse files

Add home page context

parent 19880389
Branches
No related tags found
No related merge requests found
...@@ -11,16 +11,30 @@ class HomeController extends AbstractController ...@@ -11,16 +11,30 @@ class HomeController extends AbstractController
#[Route('/', name: 'homepage')] #[Route('/', name: 'homepage')]
public function index(): Response public function index(): Response
{ {
$user = $this->getUser(); // Récupère l'utilisateur connecté
$links = [
];
// Ajoutez le lien "Admin Dashboard" uniquement si l'utilisateur est admin
if ($user && $user->isAdmin()) {
$links['Admin Dashboard'] = $this->generateUrl('admin_dashboard');
}
if (!$user) {
$links['Register'] = $this->generateUrl('register');
$links['Login'] = $this->generateUrl('login');
}
if ($user) {
$links['My Wishlists'] = $this->generateUrl('app_wishlist_index');
$links['Profile'] = $this->generateUrl('user_profile');
$links['Logout'] = $this->generateUrl('logout');
}
return $this->render('home/index.html.twig', [ return $this->render('home/index.html.twig', [
'links' => [ 'links' => $links,
'Register' => $this->generateUrl('register'),
'Login' => $this->generateUrl('login'),
'My Wishlists' => $this->generateUrl('app_wishlist_index'),
'Admin Dashboard' => $this->generateUrl('admin_dashboard'),
'Profile' => $this->generateUrl(route: 'user_profile'),
'Logout' => $this->generateUrl(route: 'logout'),
],
]); ]);
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment