src/Controller/DefaultController.php line 45

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: grego
  5.  * Date: 31/05/2022
  6.  * Time: 16:00
  7.  */
  8. namespace App\Controller;
  9. use App\Entity\Participation;
  10. use Doctrine\ORM\EntityManagerInterface;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. use Symfony\Contracts\Translation\TranslatorInterface;
  14. class DefaultController extends AbstractController
  15. {
  16.     /**
  17.      * @Route("/client", name="coss_client")
  18.      */
  19.     public function clientIndexAction(TranslatorInterface $translator)
  20.     {
  21.         $user $this->getUser();
  22.         if($user && (
  23.             in_array('ROLE_SUPER_ADMIN'$user->getRoles())
  24.             || in_array('ROLE_COMPANY_ADMIN'$user->getRoles())
  25.             || in_array('ROLE_CAMPAIGN_ADMIN'$user->getRoles()))) {
  26.             return $this->redirectToRoute('client_admin_list_campaigns');
  27.         } else {
  28.             if ($user) {
  29.                 $msg $translator->trans(
  30.                     "Vous n'avez pas accès à l'interface client COSS 360",
  31.                     array(), 'coss'
  32.                 );
  33.                 $this->addFlash("error"$msg);
  34.             }
  35.             return $this->redirectToRoute("client_login");
  36.         }
  37.     }
  38.     /**
  39.      * @Route("/", name="coss_participant")
  40.      */
  41.     public function participantIndexAction(EntityManagerInterface $entityManagerTranslatorInterface $translator)
  42.     {
  43.         $user $this->getUser();
  44.         if($user && (in_array('ROLE_COSS_USER'$user->getRoles()))) {
  45.             return $this->redirectToRoute('participation_auth_login');
  46.         } else {
  47.             if ($user) {
  48.                 $msg $translator->trans(
  49.                     "Vous n'avez pas accès à l'interface COSS 360",
  50.                     array(), 'coss'
  51.                 );
  52.                 $this->addFlash("error"$msg);
  53.             }
  54.             return $this->redirectToRoute("participation_auth_login");
  55.         }
  56.     }
  57. }