<?php
namespace App\Controller;
use App\Service\ConfigurationService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
class IndexController extends AbstractController
{
/**
* @var SessionInterface
*/
private $session;
/**
* IndexController constructor.
* @param SessionInterface $session
*/
public function __construct(SessionInterface $session)
{
$this->session=$session;
}
/**
* @Route("/", name="index")
*/
public function index(Request $request)
{
if($this->isGranted('ROLE_ADMIN')){
return $this->redirectToRoute('admin_index');
}elseif ($this->isGranted('ROLE_USER')){
return $this->redirectToRoute('cashbox_index');
}else{
return $this->redirectToRoute('app_login',['_locale'=>'de']);
}
}
/**
* @Route("/{_locale}", name="locale_index")
*/
public function localeIndex(Request $request)
{
return $this->index($request);
}
/**
* @Route("/el", name="el")
* @param Request $request
* @param ConfigurationService $configurationService
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function el(Request $request, ConfigurationService $configurationService)
{
$conf=$configurationService->getConfiguration();
// dd(openssl_encrypt('hallo',$conf['PLATFORM_CYPHER'],$_ENV['APP_SECRET'],0,$conf['PLATFORM_CYPHER_IV']));
if($this->isGranted('ROLE_ADMIN')){
return $this->redirectToRoute('admin_index');
}elseif ($this->isGranted('ROLE_USER')){
return $this->redirectToRoute('cashbox_index');
}else{
return $this->redirectToRoute('app_login');
}
}
/**
* @Route("/dummy", name="dummy")
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function dummy(Request $request)
{
return new Response('test');
}
}