<?php
namespace App\Controller;
use App\Repository\CookieRepository;
use App\Repository\PhotoRepository;
use App\Repository\UserRepository;
use DateTime;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class HomeController extends AbstractController
{
/**
* @Route("/", name="home")
*/
public function index(CookieRepository $cookieRepo, PhotoRepository $photoRepo, UserRepository $userRepo): Response
{
return $this->render('home/index.html.twig', [
'cookie' => $cookieRepo->findCookie(true)
]);
}
/**
* @Route("/tdb", name="tdb")
*/
public function tdb(): Response
{
if ($this->getUser()) {
switch ($this->getUser()->getRoles()[0]) {
case 'ROLE_ADMIN':
return $this->redirectToRoute('admin_category_index');
break;
case 'ROLE_PRESCRIPTEUR':
return $this->redirectToRoute('prescripteur_index');
break;
case 'ROLE_PHARMACIE':
return $this->redirectToRoute('pharmacie_index');
break;
case 'ROLE_GROSSISTE':
return $this->redirectToRoute('grossiste_catalogue');
break;
default:
return $this->redirectToRoute('home');
break;
}
return $this->redirectToRoute('login');
}
$this->addFlash('info', 'Session expirer, veuillez vous authentifier');
return $this->render('register/login.html.twig');
}
}