<?php
namespace App\Controller\Cliente;
use App\Repository\Questionario231DestinatarioRepository;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
/**
* Controller usato come base di smistamento subito dopo il login
* in case al ruolo, poi, gli carico la giusta dashboard
*
* @Route("/")
*/
class DashboardController extends AbstractController
{
/**
* @Route("/", name="default_dashboard")
*/
public function index()
{
$isCliente = $this->isGranted('ROLE_CLIENTE');
$isSuperAdmin = $this->isGranted('ROLE_SUPER_ADMIN');
$isAdmin = $this->isGranted('ROLE_ADMIN');
$isLawyer = $this->isGranted('ROLE_LAWYER');
$isSecretary = $this->isGranted('ROLE_SECRETARY');
if($isCliente){
return $this->redirectToRoute('cliente_dashboard');
}
if($isSuperAdmin){
return $this->redirectToRoute('admin_dashboard');
}
if($isAdmin){
return $this->redirectToRoute('admin_dashboard');
}
if($isLawyer){
return $this->redirectToRoute('admin_dashboard');
}
if($isSecretary){
return $this->redirectToRoute('admin_dashboard');
}
return $this->redirectToRoute('security_login');
//return $this->render('default/dashboard/index.html.twig', []);
}
/**
* @Route("/cliente", name="cliente_dashboard")
*/
public function clienteDashboard(Questionario231DestinatarioRepository $destinatarioRepository)
{
return $this->render('cliente/dashboard/index.html.twig', [
'destinatari' => $destinatarioRepository->getUserDestinatario($this->getUser()->getId())
]);
}
}