src/Controller/Admin/ModuleController.php line 87

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use App\Entity\Module;
  4. use App\Entity\ModuleInscription;
  5. use App\Entity\ModuleItem;
  6. use App\Entity\ModuleParticipation;
  7. use App\Entity\ModuleView;
  8. use App\Entity\User;
  9. use App\Form\ModuleInscriptionType;
  10. use App\Form\ModuleType;
  11. use App\Helper\ControllerHelper;
  12. use App\Message\Notification;
  13. use App\Repository\ModuleInscriptionRepository;
  14. use App\Repository\ModuleItemRepository;
  15. use App\Repository\ModuleParticipationRepository;
  16. use App\Repository\UserModuleParticipationRepository;
  17. use App\Repository\ModuleRepository;
  18. use App\Repository\ModuleViewRepository;
  19. use App\Repository\LiveViewRepository;
  20. use App\Repository\CourseViewRepository;
  21. use App\Repository\QuizViewRepository;
  22. use App\Repository\UserRepository;
  23. use App\Service\HelperService;
  24. use App\Service\PushNotification;
  25. use App\Utils\Constants;
  26. use DateTime;
  27. use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
  28. use Doctrine\ORM\EntityManagerInterface;
  29. use Doctrine\Persistence\ManagerRegistry;
  30. use Exception;
  31. use Kreait\Firebase\Contract\Messaging;
  32. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  33. use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
  34. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  35. use Symfony\Component\HttpFoundation\Request;
  36. use Symfony\Component\HttpFoundation\Response;
  37. use Symfony\Component\Routing\Annotation\Route;
  38. use Symfony\Component\Security\Core\User\UserInterface;
  39. use Symfony\Component\String\Slugger\SluggerInterface;
  40. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  41. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  42. use Symfony\Bridge\Twig\Mime\TemplatedEmail;
  43. use Symfony\Component\Form\Extension\Core\Type\TextType;
  44. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  45. use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
  46. use Symfony\Component\Mailer\MailerInterface;
  47. use Symfony\Component\Mercure\HubInterface;
  48. use Symfony\Component\Messenger\MessageBusInterface;
  49. use Symfony\Component\Mime\Address;
  50. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  51. use Symfony\Component\Routing\Router;
  52. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  53. /**
  54.  * @Route("/dashboard")
  55.  */
  56. class ModuleController extends AbstractController
  57. {    
  58.     use ControllerHelper
  59.     
  60.     private $slugger;
  61.     private $helperService;
  62.     private $pushNotification;
  63.     private $messaging;
  64.     private $hub;
  65.     private $bus;
  66.     public function __construct(SluggerInterface $sluggerHelperService $helperServicePushNotification $pushNotificationMessaging $messagingHubInterface $hubMessageBusInterface $bus)
  67.     {
  68.         $this->slugger $slugger;
  69.         $this->helperService $helperService;
  70.         $this->pushNotification $pushNotification;
  71.         $this->messaging $messaging;
  72.         $this->hub $hub;
  73.         $this->bus $bus;
  74.     }
  75.     /**
  76.      * Require ROLE_ADMIN or ROLE_INTEGRATOR for this action
  77.      *
  78.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR')")
  79.      * 
  80.      * @Route("/{profil}/{id}/modifier-module", name="app_module_edit", methods={"GET", "POST"})
  81.      */
  82.     public function edit(Request $requestModule $moduleModuleRepository $moduleRepositoryModuleItemRepository $moduleItemRepositoryManagerRegistry $doctrineString $profil): Response
  83.     {
  84.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR')) throw $this->createNotFoundException("La page demandée n'existe pas");
  85.         $form $this->createForm(ModuleType::class, $module);
  86.         $form->handleRequest($request);
  87.         if ($form->isSubmitted() && $form->isValid()) {
  88.             $quiz $module->getQuiz();
  89.             $quizAdded $quiz->getInsertDiff();
  90.             $quizRemoved $quiz->getDeleteDiff();
  91.             $courses $module->getCourses();
  92.             $coursesAdded $courses->getInsertDiff();
  93.             $coursesRemoved $courses->getDeleteDiff();
  94.             $moduleRepository->add($moduletrue);
  95.             foreach ($coursesAdded as $course) {
  96.                 // $moduleItem = $moduleItemRepository->findOneBy(['module' => $module, 'course' => $course]);
  97.                 // if ($moduleItem === null) {
  98.                     $moduleItem = new ModuleItem();
  99.                     $moduleItem->setModule($module);
  100.                     $moduleItem->setCourse($course);
  101.                     $moduleItem->setType('course');
  102.                     $moduleItemRepository->add($moduleItemtrue);
  103.                 // }
  104.             }
  105.             foreach ($coursesRemoved as $course) {
  106.                 $moduleItem $moduleItemRepository->findOneBy(['module' => $module'course' => $course]);
  107.                 if ($moduleItem !== null) {
  108.                     $moduleItemRepository->remove($moduleItemtrue);
  109.                 }
  110.             }
  111.             foreach ($quizAdded as $quiz) {
  112.                 // $moduleItem = $moduleItemRepository->findOneBy(['module' => $module, 'quiz' => $quiz]);
  113.                 // if ($moduleItem === null) {
  114.                     $moduleItem = new ModuleItem();
  115.                     $moduleItem->setModule($module);
  116.                     $moduleItem->setQuiz($quiz);
  117.                     $moduleItem->setType('quiz');
  118.                     $moduleItemRepository->add($moduleItemtrue);
  119.                 // }
  120.             }
  121.             foreach ($quizRemoved as $quiz) {
  122.                 $moduleItem $moduleItemRepository->findOneBy(['module' => $module'quiz' => $quiz]);
  123.                 if ($moduleItem !== null) {
  124.                     $moduleItemRepository->remove($moduleItemtrue);
  125.                 }
  126.             }
  127.             $this->addFlash("module_updated""Le module ".$module->getLabel()." a été mis à jour");
  128.             return $this->redirectToRoute('app_front_module_page', ['profil' =>  $profil], Response::HTTP_SEE_OTHER);
  129.         }
  130.         // return $this->renderForm('admin/module/edit.html.twig', [
  131.         return $this->renderForm('front/pages/dashboard/modules/create_module.html.twig', [
  132.             'module' => $module,
  133.             'form' => $form,
  134.             'profil' => $profil
  135.         ]);
  136.     }
  137.     /**
  138.      * Require ROLE_ADMIN or ROLE_INTEGRATOR for this action
  139.      *
  140.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR')")
  141.      * 
  142.      * @Route("/{profil}/{id}/supprimer-module", name="app_module_delete", methods={"POST", "GET"})
  143.      */
  144.     public function delete(Module $moduleModuleRepository $moduleRepositoryString $profil): Response
  145.     {
  146.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR')) throw $this->createNotFoundException("La page demandée n'existe pas");
  147.         $title $module->getLabel();
  148.         try {
  149.             // if ($this->isCsrfTokenValid('delete'.$module->getId(), $request->request->get('_token'))) {
  150.             $moduleRepository->remove($moduletrue);
  151.             // }
  152.             $this->addFlash("module_deleted""Le module ".$title." a été supprimé");
  153.         } catch (ForeignKeyConstraintViolationException $e) {
  154.             $this->addFlash('module_deletion_error'"Impossible de supprimer le module ".$title.". Il est lié à d'autres éléments");
  155.         }
  156.         return $this->redirectToRoute('app_front_module_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  157.     }
  158.     /**
  159.      * @Route("/modules/{slug}/item-order", name="module_item_order")
  160.      * @param Request $request
  161.      * @return JsonResponse
  162.      */
  163.     public function moduleOrder(Request $requestModuleItemRepository $moduleItemRepositoryModule $module)
  164.     {
  165.         $itemId = (int) $request->get('id');
  166.         $type $request->get('type');
  167.         $order = (int) $request->get('order');
  168.         if ($type !== null && $itemId !== null) {
  169.             $moduleItem $moduleItemRepository->findItemByTypeAndId($module$type$itemId);
  170.             if ($moduleItem !== null) {
  171.                 $moduleItem->setItemOrder($order);
  172.                 $moduleItem->setUpdatedAt(new DateTime());
  173.                 $moduleItemRepository->add($moduleItemtrue);
  174.                 return $this->json("OK OK");
  175.             }
  176.             
  177.             return $this->json("OK");
  178.         }
  179.         
  180.         return $this->json("KO");
  181.     }
  182.     /**
  183.      * Require ROLE_ADMIN or ROLE_INTEGRATOR or ROLE_ADVISE or ROLE_TUTOR or ROLE_COACH for this action
  184.      *
  185.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR') or is_granted('ROLE_ADVISE') or is_granted('ROLE_TUTOR') or is_granted('ROLE_COACH')")
  186.      * 
  187.      * @Route("/{profil}/{id}/participants-module", name="app_dashboard_module_participant_page", methods={"GET", "POST"})
  188.      */
  189.     public function participant(Request $requestModule $moduleModuleParticipationRepository $moduleParticipationRepositoryUserRepository $userRepositoryModuleRepository $moduleRepositoryString $profil): Response
  190.     {
  191.         $session $request->getSession();
  192.         if ($request->query->get('page') === null$session->remove('module_participant_search_key');
  193.         $page = (int)$request->query->get('page'1);
  194.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  195.         // Search form
  196.         $searchKey $session->has('module_participant_search_key') ? $session->get('module_participant_search_key') : null;
  197.         $form $this->createFormBuilder()
  198.         ->add('searchKey'TextType::class, [
  199.             'label' => 'Rechercher: ',
  200.             'label_attr' => ['class' => 'text-grey'],
  201.             'attr' => [
  202.                 'style' => 'border: 1px solid transparent !important'
  203.             ],
  204.             'required' => false,
  205.             'data' => $session->has('module_participant_search_key') ? $session->get('module_participant_search_key') : ''
  206.         ])
  207.         ->getForm();
  208.         
  209.         $form->handleRequest($request);
  210.         if ($form->isSubmitted() && $form->isValid()) {
  211.             $searchKey $form->get('searchKey')->getData();
  212.             $session->remove('module_participant_search_key');
  213.             if ($searchKey !== null$session->set('module_participant_search_key'$searchKey);
  214.         }
  215.         // $moduleParticipants = $moduleParticipationRepository->findModuleParticipations($module, $this->getUser(), $page, Constants::PAGINATION_LIMIT, $searchKey);
  216.         $moduleParticipants $moduleParticipationRepository->_findParticipations($module$this->getUser(), $pageConstants::PAGINATION_LIMIT$searchKey);
  217.         $moduleParticipantCount $moduleParticipationRepository->_findParticipations($module$this->getUser(), nullnull$searchKey);
  218.         // $moduleParticipants = $userRepository->findModuleParticipants($module, $this->getUser(), $this->helperService->getUserCurrentRole(), $page, Constants::PAGINATION_LIMIT);
  219.         // $moduleParticipantCount = $moduleParticipationRepository->getModuleParticipationsCount($module, $this->getUser(), $searchKey);
  220.         // $moduleParticipantCount = $userRepository->getModuleParticipantCount($module, $this->getUser(), $this->helperService->getUserCurrentRole());
  221.         return $this->renderForm('front/pages/dashboard/modules/module-participant.html.twig', [
  222.             'module' => $module,
  223.             'module_participants' => $moduleParticipants,
  224.             'module_participation_count' => isset($moduleParticipantCount['unionCount']) ? $moduleParticipantCount['unionCount'] : 0,
  225.             'limit' => Constants::PAGINATION_LIMIT,
  226.             'page' => $page,
  227.             'form' => $form
  228.         ]);
  229.     }
  230.     /**
  231.      * Require ROLE_ADMIN or ROLE_INTEGRATOR or ROLE_ADVISE or ROLE_TUTOR or ROLE_COACH for this action
  232.      *
  233.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR') or is_granted('ROLE_ADVISE') or is_granted('ROLE_TUTOR') or is_granted('ROLE_COACH')")
  234.      * 
  235.      * @Route("/{profil}/{id}/modules/inscription-participant", name="app_dashboard_add_module_participant_page", methods={"GET", "POST"})
  236.      */
  237.     public function addParticipant(Request $requestModule $moduleModuleInscriptionRepository $moduleInscriptionRepositoryMailerInterface $mailerString $profil): Response
  238.     {
  239.         $moduleInscription = new ModuleInscription();
  240.         $form $this->createForm(ModuleInscriptionType::class, $moduleInscription, ['module' =>  $module]);
  241.         $form->handleRequest($request);
  242.         if ($form->isSubmitted() && $form->isValid()) {
  243.             $toAddresses = [];
  244.             $count 0;
  245.             $participants $form->get('users')->getData();
  246.             foreach ($participants as $participant) {
  247.                 $_moduleInscription $moduleInscriptionRepository->findOneBy(['module' => $module'user' => $participant]);
  248.                 if ($_moduleInscription === null) {
  249.                     $moduleInscription = new ModuleInscription();
  250.                     $moduleInscription->setModule($module);
  251.                     $moduleInscription->setUser($participant);
  252.                     
  253.                     $moduleInscriptionRepository->add($moduleInscriptiontrue);
  254.                     $toAddresses [] = $participant->getEmail();
  255.                     $count++;
  256.                 }
  257.             }
  258.             if (count($toAddresses) > 0) {
  259.                 $url 'https:'.$this->generateUrl('app_front_library_module_details_page', ['slug' => $module->getSlug()], UrlGeneratorInterface::NETWORK_PATH);
  260.                 $mail = (new TemplatedEmail())
  261.                     ->from(new Address($this->getParameter('cofina_sender_mail'), 'Cofina Academy'))
  262.                     ->to(...$toAddresses)
  263.                     ->subject('Inscription au Module')
  264.                     ->htmlTemplate('front/pages/dashboard/modules/inscription-mail.html.twig')
  265.                     ->context([
  266.                         'name' => $module->getName(),
  267.                         'startAt' => $module->getStartAt(),
  268.                         'endAt' => $module->getEndAt(),
  269.                         'library_homepage_url' => $url
  270.                     ])
  271.                 ;
  272.                 try {
  273.                     $mailer->send($mail);
  274.                 } catch (TransportExceptionInterface $e) {
  275.                 }
  276.             }
  277.             try {
  278.                 $mailer->send($mail);
  279.                 $this->bus->dispatch(new Notification($module->getId(), 'Module''module_participation'$module->getCreatedBy()->getId()));
  280.             } catch (Exception $e) {
  281.             }
  282.             $this->addFlash('module_participants_added'$count.' participant(s) ajouté(s) au module');
  283.             return $this->redirectToRoute('app_dashboard_module_participant_page', ['id' => $module->getId(), 'profil' => $profil], Response::HTTP_SEE_OTHER);
  284.         }
  285.         return $this->renderForm('front/pages/dashboard/modules/add-module-participant.html.twig', [
  286.             'module' => $module,
  287.             'form' => $form
  288.         ]);
  289.     }
  290.     /**
  291.      * Require ROLE_ADMIN or ROLE_INTEGRATOR or ROLE_ADVISE or ROLE_TUTOR or ROLE_COACH for this action
  292.      *
  293.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR') or is_granted('ROLE_ADVISE') or is_granted('ROLE_TUTOR') or is_granted('ROLE_COACH')")
  294.      *
  295.      * @Route("/{profil}/{id}/participants-module/exporter", name="app_dashboard_module_export_participant_page", methods={"GET", "POST"})
  296.      * @throws Exception
  297.      */
  298.     public function exportParticipant(Module $moduleUserRepository $userRepositoryModuleParticipationRepository $moduleParticipationRepositoryString $profil){
  299.         //$moduleParticipants = $userRepository->findModuleParticipants($module, $this->getUser(), $this->helperService->getUserCurrentRole());
  300.         $moduleParticipants $moduleParticipationRepository->findModuleParticipations($module$this->getUser());
  301.         $spreadsheet = new Spreadsheet();
  302.         $sheet $spreadsheet->getActiveSheet();
  303.         $title $this->formatTitleForExport($module->getName());
  304.         $sheet->setTitle($title);
  305.         $sheet->setCellValue('A1''Liste de participants')
  306.             ->setCellValue('B1''Email');
  307.         // if ($role === 'ROLE_ADVISE' || $role === 'ROLE_TUTOR'){
  308.             $sheet->setCellValue('C1''Filiale');
  309.         // }
  310.         $row 2;
  311.         foreach ($moduleParticipants as $participant){
  312.             $sheet->setCellValue("A{$row}"$participant->getCreatedBy()->getFullName())
  313.                 ->setCellValue("B{$row}"$participant->getCreatedBy()->getEmail());
  314.             // if (($role === 'ROLE_ADVISE' || $role === 'ROLE_TUTOR')){
  315.                 $sheet->setCellValue("C{$row}", ($participant->getCreatedBy()->getSubsidiaryCompany() !== null) ? $participant->getCreatedBy()->getSubsidiaryCompany()->getName() : "");
  316.             // }
  317.             $row++;
  318.         }
  319.         $writer = new Xlsx($spreadsheet);
  320.         $fileName $title.".xlsx";
  321.         $temp_file tempnam(sys_get_temp_dir(), $fileName);
  322.         $writer->save($temp_file);
  323.         return $this->file($temp_file$fileNameResponseHeaderBag::DISPOSITION_INLINE);
  324.     }
  325.     /**
  326.      * Require ROLE_ADMIN for this action
  327.      *
  328.      * @Security("is_granted('ROLE_ADMIN')")
  329.      *
  330.      * @Route("/{profil}/{participation_id}/supprimer-participation-module", name="app_module_participation_delete", methods={"GET", "POST"})
  331.      * @Route("/{profil}/{inscription_id}/supprimer-inscription-module", name="app_module_inscription_delete", methods={"GET", "POST"})
  332.      * @ParamConverter("moduleParticipation", isOptional="true", options={"mapping": {"participation_id": "id"}})
  333.      * @ParamConverter("moduleInscription", isOptional="true", options={"mapping": {"inscription_id": "id"}})
  334.      * @throws Exception
  335.      */
  336.     public function deleteModuleParticipant
  337.         Request $request,
  338.         ModuleParticipationRepository $moduleParticipationRepository
  339.         UserModuleParticipationRepository $userModuleParticipationRepository
  340.         LiveViewRepository $liveViewRepository
  341.         QuizViewRepository $quizViewRepository,
  342.         CourseViewRepository $courseViewRepository,
  343.         ?ModuleParticipation $moduleParticipation,
  344.         ?ModuleInscription $moduleInscription,
  345.         String $profil
  346.     ) {
  347.         if ($moduleParticipation === null && $moduleInscription === null) return $this->redirect($request->headers->get('referer'));
  348.         $participant = ($moduleParticipation !== null) ? $moduleParticipation->getCreatedBy() : $moduleInscription->getUser();
  349.         $module = ($moduleParticipation !== null) ? $moduleParticipation->getModule() : $moduleInscription->getModule();
  350.         $userModuleParticipations $userModuleParticipationRepository->findBy(array('module' => $module'createdBy' => $participant));
  351.         foreach($userModuleParticipations as $userModuleParticipation) {
  352.             $userModuleParticipationRepository->remove($userModuleParticipationtrue);
  353.         }
  354.         $moduleParticipations $moduleParticipationRepository->findBy(array('module' => $module'createdBy' => $participant));
  355.         
  356.         foreach($moduleParticipations as $moduleParticipation) {
  357.             if($moduleParticipation->getQuiz()) {
  358.                 $quizViews $quizViewRepository->findBy(array('quiz' => $moduleParticipation->getQuiz(), 'createdBy' => $participant));
  359.                 foreach($quizViews as $quizView) {
  360.                     $quizViewRepository->remove($quizViewtrue);
  361.                 }
  362.             }
  363.             if($moduleParticipation->getLive()) {
  364.                 $liveViews $liveViewRepository->findBy(array('live' => $moduleParticipation->getLive(), 'createdBy' => $participant));
  365.                 foreach($liveViews as $liveView) {
  366.                     $liveViewRepository->remove($liveViewtrue);
  367.                 }
  368.             }
  369.             if($moduleParticipation->getCourse()) {
  370.                 $courseViews $courseViewRepository->findBy(array('course' => $moduleParticipation->getCourse(), 'createdBy' => $participant));
  371.                 foreach($courseViews as $courseView) {
  372.                     $courseViewRepository->remove($courseViewtrue);
  373.                 }
  374.             }
  375.             
  376.             $moduleParticipationRepository->remove($moduleParticipationtrue);
  377.         }
  378.         $this->addFlash("module_participation_deleted""La participation de ".$participant->getLastname()." ".$participant->getFirstname()." a été supprimée.");
  379.  
  380.         return $this->redirectToRoute('app_dashboard_module_participant_page', ['profil' => $profil'id' => $module->getId()], Response::HTTP_SEE_OTHER);
  381.     }
  382.     /**
  383.      * Require ROLE_ADMIN or ROLE_INTEGRATOR or ROLE_ADVISE or ROLE_TUTOR or ROLE_COACH for this action
  384.      *
  385.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR') or is_granted('ROLE_ADVISE') or is_granted('ROLE_TUTOR') or is_granted('ROLE_COACH')")
  386.      * 
  387.      * @Route("/{profil}/{slug}/modules/send-notification", name="app_dashboard_module_send_notification", methods={"GET", "POST"})
  388.      */
  389.     public function sendNotification(Module $moduleUserRepository $userRepositoryString $profil): Response
  390.     {
  391.         // $programs = $module->getPrograms();
  392.         // $topics = [];
  393.         // $deviceTokens = [];
  394.         // $users = [];
  395.         // if (!$programs->isEmpty()) {
  396.         //     foreach ($programs as $program) {
  397.         //         $topic = $this->slugger->slug(strtolower('program_'.$program->getLabel().'_user_to_notified_id'))->toString();
  398.         //         $topics [] = $topic;
  399.         //         $users = $userRepository->findSubscribers($program->getSubsidiaryCompanies());
  400.         //         $users = array_merge($users, $program->getUsers()->toArray());
  401.         //     }
  402.         //     $moduleInscriptions = $module->getModuleInscriptions();
  403.         //     foreach ($moduleInscriptions as $moduleInscription) {
  404.         //         $user = $moduleInscription->getUser();
  405.         //         if (!in_array($user, $users)) $users [] = $user;
  406.         //     }
  407.         //     if (!empty($users)) $notification = $this->helperService->createNotification($module, [], 'new_module');
  408.         //     $indexToRemove = array_search($this->getUser(), $users);
  409.         //     if ($indexToRemove !== false) unset($users[$indexToRemove]);
  410.         //     foreach ($users as $user) {
  411.         //         $deviceTokens = $user->getDeviceTokens();
  412.         //         $topics = array_map(function($item) use ($user) {
  413.         //             return str_replace('user-to-notified-id', $user->getId(), $item);
  414.         //         }, $topics);
  415.         //         if ($deviceTokens !== null && !empty($deviceTokens)) {
  416.         //             $this->messaging->subscribeToTopics($topics, $deviceTokens);
  417.         //         }
  418.         //         $this->pushNotification->sendNotification($module->getCreatedBy(), $user, $topics, 'new_module', $module, false, $notification);
  419.         //         $this->pushNotification->sendNotification($module->getCreatedBy(), $user, $topics, 'new_module', $module, true);
  420.         //     }
  421.         // } else $topics [] = Constants::DEFAULT_TOPIC;
  422.         try {
  423.             /** @var User $user */
  424.             $user $this->getUser();
  425.             $this->bus->dispatch(new Notification($module->getId(), 'Module''new_module'$user->getId()));
  426.         } catch (Exception $e) {
  427.         }
  428.         $flashMessage "Notification envoyé";
  429.         $this->addFlash("new_module_push_notification"$flashMessage);
  430.         return $this->redirectToRoute('app_front_module_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  431.     }
  432. }