src/Controller/Main/DefaultController.php line 11

  1. <?php
  2. namespace App\Controller\Main;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. class DefaultController extends AbstractController
  7. {
  8.     public function appRouter(): Response
  9.     {
  10.         // bu fos js routing e aktarıyor hatalı
  11.         if (!$this->getUser()) {
  12.             return $this->redirectToRoute("app_login");
  13.         }
  14.         
  15.         $roles $this->getUser()->getRoles();
  16.         
  17.         if ($this->isGranted("ROLE_ADMIN")) {
  18.             return $this->redirectToRoute("admin_user");
  19.         } else if ($this->isGranted("ROLE_KULLANICI")) {
  20.             return $this->redirectToRoute("main_index");
  21.         } else {
  22.             return $this->redirectToRoute("app_login");
  23.         }
  24.     }
  25. }