src/Controller/IndexController.php line 46

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Service\ConfigurationService;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\HttpFoundation\Request;
  9. class IndexController extends AbstractController
  10. {
  11.     /**
  12.      * @var SessionInterface
  13.      */
  14.     private $session;
  15.     /**
  16.      * IndexController constructor.
  17.      * @param SessionInterface $session
  18.      */
  19.     public function __construct(SessionInterface $session)
  20.     {
  21.         $this->session=$session;
  22.     }
  23.     /**
  24.      * @Route("/", name="index")
  25.      */
  26.     public function index(Request $request)
  27.     {
  28.         if($this->isGranted('ROLE_ADMIN')){
  29.             return $this->redirectToRoute('admin_index');
  30.         }elseif ($this->isGranted('ROLE_USER')){
  31.             return $this->redirectToRoute('cashbox_index');
  32.         }else{
  33.             return $this->redirectToRoute('app_login',['_locale'=>'de']);
  34.         }
  35.     }
  36.     /**
  37.      * @Route("/{_locale}", name="locale_index")
  38.      */
  39.     public function localeIndex(Request $request)
  40.     {
  41.         return $this->index($request);
  42.     }
  43.     /**
  44.      * @Route("/el", name="el")
  45.      * @param Request $request
  46.      * @param ConfigurationService $configurationService
  47.      * @return \Symfony\Component\HttpFoundation\RedirectResponse
  48.      */
  49.     public function el(Request $requestConfigurationService $configurationService)
  50.     {
  51.         $conf=$configurationService->getConfiguration();
  52. //        dd(openssl_encrypt('hallo',$conf['PLATFORM_CYPHER'],$_ENV['APP_SECRET'],0,$conf['PLATFORM_CYPHER_IV']));
  53.         if($this->isGranted('ROLE_ADMIN')){
  54.             return $this->redirectToRoute('admin_index');
  55.         }elseif ($this->isGranted('ROLE_USER')){
  56.             return $this->redirectToRoute('cashbox_index');
  57.         }else{
  58.             return $this->redirectToRoute('app_login');
  59.         }
  60.     }
  61.     /**
  62.      * @Route("/dummy", name="dummy")
  63.      * @param Request $request
  64.      * @return \Symfony\Component\HttpFoundation\Response
  65.      */
  66.     public function dummy(Request $request)
  67.     {
  68.         return new Response('test');
  69.     }
  70. }