<?php
namespace App\Controller;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Psr\Log\LoggerInterface;
use App\Repository\UserRepository;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use App\Repository\PermissionRepository;
use Symfony\Component\Security\Core\Security;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use App\Entity\User;
use App\Form\UserType;
class DefaultController extends AbstractController
{
public function __construct(Security $security)
{
$this->security = $security;
}
/**
* @Route("/", name="app_index")
*/
public function index(UrlGeneratorInterface $urlGenerator): Response
{
$user = $this->security->getUser();
if($user){
return new RedirectResponse($urlGenerator->generate('app_index_solution'));
}
return new RedirectResponse($urlGenerator->generate('app_login'));
// return $this->generateUrl('app_login');
//return $this->render('security/login.html.twig');
}
}