From 9df1a9e74a1bb43ff7db39c34372902e4c340c2d Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Tue, 14 Nov 2023 11:04:32 +0100 Subject: [PATCH] Event talk submit in user land --- src/Controller/UserAccount/TalkController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Controller/UserAccount/TalkController.php b/src/Controller/UserAccount/TalkController.php index b869ae85..46dc0d9f 100644 --- a/src/Controller/UserAccount/TalkController.php +++ b/src/Controller/UserAccount/TalkController.php @@ -4,12 +4,14 @@ use App\Entity\Talk; use App\Entity\User; +use App\Event\NewTalkSubmittedEvent; use App\Form\UserAccount\EditTalkType; use App\Form\UserAccount\NewTalkType; use App\Repository\TalkRepository; use Doctrine\ORM\EntityManagerInterface; use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -20,6 +22,7 @@ class TalkController extends AbstractController public function __construct( private TalkRepository $talkRepository, private EntityManagerInterface $em, + private EventDispatcherInterface $eventDispatcher, ) { } @@ -44,6 +47,7 @@ public function userTalks(Request $request): Response ); $this->addFlash('info', $message); + $this->eventDispatcher->dispatch(new NewTalkSubmittedEvent($talk, $talk->getSubmits()->toArray())); return $this->redirectToRoute('user_talks'); }