src/Controller/CPanel.php line 21

  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\NavigationItem;
  4. use App\Repository\NavigationItemRepository;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Polyfill\Intl\Icu\Exception\NotImplementedException;
  8. class CPanel extends AbstractController {
  9.     #[Route("/rutas"name:"app_rutas"methods:["POST"])]
  10.     public function getRoutes(NavigationItemRepository $nirepo){
  11.         $this->denyAccessUnlessGranted("ROLE_USER");
  12.         $rutas $nirepo->createQueryBuilder("ni")->orderBy("ni.prioridad""asc")->getQuery()->getResult();
  13.         $rutas array_filter($rutas, fn(NavigationItem $ni) => $this->isGranted($ni->getMinimumRole()));
  14.         $rutas array_map(fn(NavigationItem $ni) => $ni->serialize(), $rutas);
  15.         return $this->json($rutas);
  16.     }
  17.     #[Route("/cPanel/dashboard"name"cPanel_index")]
  18.     public function index(){
  19.         $this->denyAccessUnlessGranted("ROLE_EMPLEADO");
  20.         return $this->render("cPanel/index.twig");
  21.     }
  22.     #[Route("/loginCPanel"name"cPanel_login")]
  23.     public function login(){
  24.         if ($this->getUser()) return $this->redirect($this->generateUrl("cPanel_index"));
  25.         return $this->render("cPanel/login.twig");
  26.     }
  27.     #[Route("logout"name"logout")]
  28.     public function logout(){
  29.         return new NotImplementedException("No es necesario");
  30.     }
  31. }