src/Controller/DefaultController.php line 40

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Component\Process\Process;
  4. use Symfony\Component\Process\Exception\ProcessFailedException;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\HttpFoundation\StreamedResponse;
  10. use Symfony\Component\HttpFoundation\JsonResponse;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
  13. use Psr\Log\LoggerInterface;
  14. use App\Repository\UserRepository;
  15. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  16. use App\Repository\PermissionRepository;
  17. use Symfony\Component\Security\Core\Security;
  18. use Doctrine\ORM\EntityManagerInterface;
  19. use Symfony\Component\Serializer\Serializer;
  20. use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
  21. use Symfony\Component\Serializer\SerializerInterface;
  22. use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
  23. use Symfony\Component\HttpFoundation\RedirectResponse;
  24. use App\Entity\User;
  25. use App\Form\UserType;
  26. class DefaultController extends AbstractController
  27. {
  28.     public function __construct(Security $security)
  29.     {
  30.        $this->security $security;
  31.     }
  32.     /**
  33.      * @Route("/", name="app_index")
  34.      */
  35.     public function index(UrlGeneratorInterface $urlGenerator): Response
  36.     {
  37.         $user $this->security->getUser();
  38.         if($user){
  39.             return new RedirectResponse($urlGenerator->generate('app_index_solution'));
  40.         }
  41.         return new RedirectResponse($urlGenerator->generate('app_login'));
  42.        // return $this->generateUrl('app_login');
  43.         //return $this->render('security/login.html.twig');
  44.     }
  45.    
  46. }