From 99be7d96147137e27730475dd243f8f160c847c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 26 Feb 2026 16:39:50 +0100 Subject: [PATCH] Replace `EventDispatcherInterface` with `TriggerAuditInterface` in `AccompanyingCourseController` - Migrated from `EventDispatcherInterface` to `TriggerAuditInterface` for handling audit events. - Updated all audit-related calls to use `triggerAudit` instead of `dispatch` in the controller. --- .../AccompanyingCourseController.php | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index a8d83a0dc..ba515c29f 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Controller; use Chill\ActivityBundle\Entity\Activity; -use Chill\MainBundle\Audit\AuditEvent; +use Chill\MainBundle\Audit\TriggerAuditInterface; use Chill\MainBundle\Entity\AuditTrail; use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\AccompanyingPeriod; @@ -22,7 +22,6 @@ use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepos use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter; -use Psr\EventDispatcher\EventDispatcherInterface; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; @@ -50,7 +49,7 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle private readonly Security $security, private readonly PersonRepository $personRepository, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, - private readonly EventDispatcherInterface $eventDispatcher, + private readonly TriggerAuditInterface $triggerAudit, ) {} /** @@ -77,14 +76,12 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle $em->flush(); - $this->eventDispatcher->dispatch( - new AuditEvent( - AuditTrail::AUDIT_UPDATE, - $accompanyingCourse, - [], - new TranslatableMessage('accompanying_period.audit.close'), - ['action' => 'close'] - ) + $this->triggerAudit->triggerAudit( + AuditTrail::AUDIT_UPDATE, + $accompanyingCourse, + [], + new TranslatableMessage('accompanying_period.audit.close'), + ['action' => 'close'] ); return $this->redirectToRoute('chill_person_accompanying_course_index', [ @@ -134,7 +131,7 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle $em->remove($accompanyingCourse); $em->flush(); - $this->eventDispatcher->dispatch(new AuditEvent(AuditTrail::AUDIT_DELETE, $accompanyingCourse)); + $this->triggerAudit->triggerAudit(AuditTrail::AUDIT_DELETE, $accompanyingCourse); $this->addFlash('success', $this->translator ->trans('The accompanying course has been successfully removed.')); @@ -174,12 +171,12 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $accompanyingCourse); - $this->eventDispatcher->dispatch(new AuditEvent( + $this->triggerAudit->triggerAudit( AuditTrail::AUDIT_VIEW, $accompanyingCourse, description: new TranslatableMessage('accompanying_period.audit.show_edit_page'), metadata: ['action' => 'show_edit_page'] - )); + ); return $this->render('@ChillPerson/AccompanyingCourse/edit.html.twig', [ 'accompanyingCourse' => $accompanyingCourse, @@ -213,7 +210,7 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $accompanyingCourse); - $this->eventDispatcher->dispatch(new AuditEvent(AuditTrail::AUDIT_VIEW, $accompanyingCourse)); + $this->triggerAudit->triggerAudit(AuditTrail::AUDIT_VIEW, $accompanyingCourse); // compute some warnings // get persons without household @@ -284,7 +281,7 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle $em->persist($period); $em->flush(); - $this->eventDispatcher->dispatch(new AuditEvent(AuditTrail::AUDIT_CREATE, $period)); + $this->triggerAudit->triggerAudit(AuditTrail::AUDIT_CREATE, $period); return $this->redirectToRoute('chill_person_accompanying_course_edit', [ 'accompanying_period_id' => $period->getId(), @@ -323,7 +320,7 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle $em->persist($period); $em->flush(); - $this->eventDispatcher->dispatch(new AuditEvent(AuditTrail::AUDIT_CREATE, $period)); + $this->triggerAudit->triggerAudit(AuditTrail::AUDIT_CREATE, $period); return $this->redirectToRoute('chill_person_accompanying_course_edit', [ 'accompanying_period_id' => $period->getId(), @@ -349,7 +346,7 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle $accompanyingCourse->reOpen(); $this->managerRegistry->getManager()->flush(); - $this->eventDispatcher->dispatch(new AuditEvent(AuditTrail::AUDIT_UPDATE, $accompanyingCourse, description: new TranslatableMessage('accompanying_period.audit.reopen'), metadata: ['action' => 'reopen'])); + $this->triggerAudit->triggerAudit(AuditTrail::AUDIT_UPDATE, $accompanyingCourse, description: new TranslatableMessage('accompanying_period.audit.reopen'), metadata: ['action' => 'reopen']); return $this->redirectToRoute('chill_person_accompanying_course_index', [ 'accompanying_period_id' => $accompanyingCourse->getId(),