<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Util\TargetPathTrait;
class DefaultController extends AbstractController
{
use TargetPathTrait;
/**
* @Route("/", name="homepage")
*
* @return Response
*/
public function index(): Response
{
if ($this->isGranted('ROLE_BACKEND_USER')) {
return $this->redirectToRoute('admin_homepage');
}
if ($this->isGranted('ROLE_CUSTOMER_USER')) {
return $this->redirectToRoute('client_homepage');
}
return $this->render('public/homepage.html.twig');
}
/**
* @Route("/portal", name="portal_redirect")
*
* @return RedirectResponse
*/
public function portal(): RedirectResponse
{
if ($this->isGranted('ROLE_BACKEND_USER')) {
return $this->redirectToRoute('admin_homepage');
}
if ($this->isGranted('ROLE_CUSTOMER_USER')) {
return $this->redirectToRoute('client_homepage');
}
return $this->redirectToRoute('security_login');
}
}