From cf391d60fe214dc530e8362f0dba3ab6cdc1fc20 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 18 Jun 2025 15:24:12 +0200 Subject: [PATCH] Use enums in flag providers and rename NotificationEnum to NotificationFlagEnum --- .../Controller/NotificationController.php | 12 ++++++------ src/Bundle/ChillMainBundle/Entity/Notification.php | 8 ++++---- ...NotificationEnum.php => NotificationFlagEnum.php} | 4 ++-- .../AccompanyingCourseNotificationFlagProvider.php | 3 ++- ...ingCourseWorkEvalDocNotificationFlagProvider.php} | 7 ++++--- ...ccompanyingCourseWorkNotificationFlagProvider.php | 3 ++- .../ActivityNotificationFlagProvider.php | 3 ++- .../DesignatedReferrerNotificationFlagProvider.php | 3 ++- .../PersonAddressMoveNotificationFlagProvider.php | 3 ++- .../WorkflowTransitionNotificationFlagProvider.php | 3 ++- .../EventSubscriber/NotificationOnTransition.php | 4 ++-- .../ChillMainBundle/translations/messages.fr.yml | 2 +- .../Events/PersonAddressMoveEventSubscriber.php | 4 ++-- .../Events/UserRefEventSubscriber.php | 4 ++-- 14 files changed, 35 insertions(+), 28 deletions(-) rename src/Bundle/ChillMainBundle/Entity/{NotificationEnum.php => NotificationFlagEnum.php} (83%) rename src/Bundle/ChillMainBundle/Notification/FlagProviders/{AccompanyingCourseWorkEvalNotificationFlagProvider.php => AccompanyingCourseWorkEvalDocNotificationFlagProvider.php} (59%) diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationController.php b/src/Bundle/ChillMainBundle/Controller/NotificationController.php index 0bcd227b3..d876241a5 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationController.php @@ -14,7 +14,7 @@ namespace Chill\MainBundle\Controller; use Chill\ActivityBundle\Entity\Activity; use Chill\MainBundle\Entity\Notification; use Chill\MainBundle\Entity\NotificationComment; -use Chill\MainBundle\Entity\NotificationEnum; +use Chill\MainBundle\Entity\NotificationFlagEnum; use Chill\MainBundle\Form\NotificationCommentType; use Chill\MainBundle\Form\NotificationType; use Chill\MainBundle\Notification\Exception\NotificationHandlerNotFound; @@ -62,16 +62,16 @@ class NotificationController extends AbstractController switch ($request->query->get('entityClass')) { case Activity::class: - $notificationType = NotificationEnum::ACTIVITY; + $notificationType = NotificationFlagEnum::ACTIVITY; break; case AccompanyingPeriod::class: - $notificationType = NotificationEnum::ACC_COURSE; + $notificationType = NotificationFlagEnum::ACC_COURSE; break; case AccompanyingPeriodWork::class: - $notificationType = NotificationEnum::ACC_COURSE_WORK; + $notificationType = NotificationFlagEnum::ACC_COURSE_WORK; break; - case AccompanyingPeriodWorkEvaluation::class: - $notificationType = NotificationEnum::ACC_COURSE_WORK_EVAL; + case AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument::class: + $notificationType = NotificationFlagEnum::ACC_COURSE_WORK_EVAL_DOC; break; } diff --git a/src/Bundle/ChillMainBundle/Entity/Notification.php b/src/Bundle/ChillMainBundle/Entity/Notification.php index 79741f84e..1c01ddd88 100644 --- a/src/Bundle/ChillMainBundle/Entity/Notification.php +++ b/src/Bundle/ChillMainBundle/Entity/Notification.php @@ -101,8 +101,8 @@ class Notification implements TrackUpdateInterface #[ORM\ManyToOne(targetEntity: User::class)] private ?User $updatedBy = null; - #[ORM\Column(name: 'type', type: Types::STRING, nullable: true, enumType: NotificationEnum::class)] - private NotificationEnum $type; + #[ORM\Column(name: 'type', type: Types::STRING, nullable: true, enumType: NotificationFlagEnum::class)] + private NotificationFlagEnum $type; public function __construct() { @@ -394,14 +394,14 @@ class Notification implements TrackUpdateInterface return $this; } - public function setType(NotificationEnum $type): self + public function setType(NotificationFlagEnum $type): self { $this->type = $type; return $this; } - public function getType(): NotificationEnum + public function getType(): NotificationFlagEnum { return $this->type; } diff --git a/src/Bundle/ChillMainBundle/Entity/NotificationEnum.php b/src/Bundle/ChillMainBundle/Entity/NotificationFlagEnum.php similarity index 83% rename from src/Bundle/ChillMainBundle/Entity/NotificationEnum.php rename to src/Bundle/ChillMainBundle/Entity/NotificationFlagEnum.php index a320b4ee4..2ee4345d8 100644 --- a/src/Bundle/ChillMainBundle/Entity/NotificationEnum.php +++ b/src/Bundle/ChillMainBundle/Entity/NotificationFlagEnum.php @@ -11,13 +11,13 @@ declare(strict_types=1); namespace Chill\MainBundle\Entity; -enum NotificationEnum: string +enum NotificationFlagEnum: string { case REFERRER_ACC_COURSE = 'referrer-acc-course-notif'; case PERSON_MOVE = 'person-move-notif'; case ACC_COURSE = 'acc-course-notif'; case WORKFLOW_TRANS = 'workflow-trans-notif'; case ACC_COURSE_WORK = 'acc-course-work-notif'; - case ACC_COURSE_WORK_EVAL = 'acc-course-work-eval-notif'; + case ACC_COURSE_WORK_EVAL_DOC = 'acc-course-work-eval-doc-notif'; case ACTIVITY = 'activity-notif'; } diff --git a/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseNotificationFlagProvider.php b/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseNotificationFlagProvider.php index c44b45810..50d72531a 100644 --- a/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseNotificationFlagProvider.php +++ b/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseNotificationFlagProvider.php @@ -2,6 +2,7 @@ namespace Chill\MainBundle\Notification\FlagProviders; +use Chill\MainBundle\Entity\NotificationFlagEnum; use Symfony\Component\Translation\TranslatableMessage; use Symfony\Contracts\Translation\TranslatableInterface; @@ -10,7 +11,7 @@ class AccompanyingCourseNotificationFlagProvider implements NotificationFlagProv public function getFlag(): string { - return 'acc-course-notif'; + return NotificationFlagEnum::ACC_COURSE->value; } public function getLabel(): TranslatableInterface diff --git a/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkEvalNotificationFlagProvider.php b/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkEvalDocNotificationFlagProvider.php similarity index 59% rename from src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkEvalNotificationFlagProvider.php rename to src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkEvalDocNotificationFlagProvider.php index beab802b0..3e96f6361 100644 --- a/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkEvalNotificationFlagProvider.php +++ b/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkEvalDocNotificationFlagProvider.php @@ -2,19 +2,20 @@ namespace Chill\MainBundle\Notification\FlagProviders; +use Chill\MainBundle\Entity\NotificationFlagEnum; use Symfony\Component\Translation\TranslatableMessage; use Symfony\Contracts\Translation\TranslatableInterface; -class AccompanyingCourseWorkEvalNotificationFlagProvider implements NotificationFlagProviderInterface +class AccompanyingCourseWorkEvalDocNotificationFlagProvider implements NotificationFlagProviderInterface { public function getFlag(): string { - return 'acc-course-work-eval-notif'; + return NotificationFlagEnum::ACC_COURSE_WORK_EVAL_DOC->value; } public function getLabel(): TranslatableInterface { - return new TranslatableMessage('notification.flags.acc-course-work-eval'); + return new TranslatableMessage('notification.flags.acc-course-work-eval-doc'); } } diff --git a/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkNotificationFlagProvider.php b/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkNotificationFlagProvider.php index 67e5a1cd5..b71abf5d4 100644 --- a/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkNotificationFlagProvider.php +++ b/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkNotificationFlagProvider.php @@ -2,6 +2,7 @@ namespace Chill\MainBundle\Notification\FlagProviders; +use Chill\MainBundle\Entity\NotificationFlagEnum; use Symfony\Component\Translation\TranslatableMessage; use Symfony\Contracts\Translation\TranslatableInterface; @@ -10,7 +11,7 @@ class AccompanyingCourseWorkNotificationFlagProvider implements NotificationFlag public function getFlag(): string { - return 'acc-course-work-notif'; + return NotificationFlagEnum::ACC_COURSE_WORK->value; } public function getLabel(): TranslatableInterface diff --git a/src/Bundle/ChillMainBundle/Notification/FlagProviders/ActivityNotificationFlagProvider.php b/src/Bundle/ChillMainBundle/Notification/FlagProviders/ActivityNotificationFlagProvider.php index a77a94e85..78515d72d 100644 --- a/src/Bundle/ChillMainBundle/Notification/FlagProviders/ActivityNotificationFlagProvider.php +++ b/src/Bundle/ChillMainBundle/Notification/FlagProviders/ActivityNotificationFlagProvider.php @@ -2,6 +2,7 @@ namespace Chill\MainBundle\Notification\FlagProviders; +use Chill\MainBundle\Entity\NotificationFlagEnum; use Symfony\Component\Translation\TranslatableMessage; use Symfony\Contracts\Translation\TranslatableInterface; @@ -10,7 +11,7 @@ class ActivityNotificationFlagProvider implements NotificationFlagProviderInterf public function getFlag(): string { - return 'activity-notif'; + return NotificationFlagEnum::ACTIVITY->value; } public function getLabel(): TranslatableInterface diff --git a/src/Bundle/ChillMainBundle/Notification/FlagProviders/DesignatedReferrerNotificationFlagProvider.php b/src/Bundle/ChillMainBundle/Notification/FlagProviders/DesignatedReferrerNotificationFlagProvider.php index 582cd231b..335d4339e 100644 --- a/src/Bundle/ChillMainBundle/Notification/FlagProviders/DesignatedReferrerNotificationFlagProvider.php +++ b/src/Bundle/ChillMainBundle/Notification/FlagProviders/DesignatedReferrerNotificationFlagProvider.php @@ -2,6 +2,7 @@ namespace Chill\MainBundle\Notification\FlagProviders; +use Chill\MainBundle\Entity\NotificationFlagEnum; use Symfony\Component\Translation\TranslatableMessage; use Symfony\Contracts\Translation\TranslatableInterface; @@ -10,7 +11,7 @@ class DesignatedReferrerNotificationFlagProvider implements NotificationFlagProv public function getFlag(): string { - return 'referrer-acc-course-notif'; + return NotificationFlagEnum::REFERRER_ACC_COURSE->value; } public function getLabel(): TranslatableInterface diff --git a/src/Bundle/ChillMainBundle/Notification/FlagProviders/PersonAddressMoveNotificationFlagProvider.php b/src/Bundle/ChillMainBundle/Notification/FlagProviders/PersonAddressMoveNotificationFlagProvider.php index c75c8412e..6f33fa427 100644 --- a/src/Bundle/ChillMainBundle/Notification/FlagProviders/PersonAddressMoveNotificationFlagProvider.php +++ b/src/Bundle/ChillMainBundle/Notification/FlagProviders/PersonAddressMoveNotificationFlagProvider.php @@ -2,6 +2,7 @@ namespace Chill\MainBundle\Notification\FlagProviders; +use Chill\MainBundle\Entity\NotificationFlagEnum; use Symfony\Component\Translation\TranslatableMessage; use Symfony\Contracts\Translation\TranslatableInterface; @@ -10,7 +11,7 @@ class PersonAddressMoveNotificationFlagProvider implements NotificationFlagProvi public function getFlag(): string { - return 'person-address-move-notif'; + return NotificationFlagEnum::PERSON_MOVE->value; } public function getLabel(): TranslatableInterface diff --git a/src/Bundle/ChillMainBundle/Notification/FlagProviders/WorkflowTransitionNotificationFlagProvider.php b/src/Bundle/ChillMainBundle/Notification/FlagProviders/WorkflowTransitionNotificationFlagProvider.php index a048c91a5..3e48c400c 100644 --- a/src/Bundle/ChillMainBundle/Notification/FlagProviders/WorkflowTransitionNotificationFlagProvider.php +++ b/src/Bundle/ChillMainBundle/Notification/FlagProviders/WorkflowTransitionNotificationFlagProvider.php @@ -2,6 +2,7 @@ namespace Chill\MainBundle\Notification\FlagProviders; +use Chill\MainBundle\Entity\NotificationFlagEnum; use Symfony\Component\Translation\TranslatableMessage; use Symfony\Contracts\Translation\TranslatableInterface; @@ -10,7 +11,7 @@ class WorkflowTransitionNotificationFlagProvider implements NotificationFlagProv public function getFlag(): string { - return 'workflow-trans-notif'; + return NotificationFlagEnum::WORKFLOW_TRANS->value; } public function getLabel(): TranslatableInterface diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php index af8d0537e..df0dc205c 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Workflow\EventSubscriber; use Chill\MainBundle\Entity\Notification; -use Chill\MainBundle\Entity\NotificationEnum; +use Chill\MainBundle\Entity\NotificationFlagEnum; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserGroup; use Chill\MainBundle\Entity\Workflow\EntityWorkflow; @@ -127,7 +127,7 @@ class NotificationOnTransition implements EventSubscriberInterface ->setTitle($this->engine->render('@ChillMain/Workflow/workflow_notification_on_transition_completed_title.fr.txt.twig', $context)) ->setMessage($this->engine->render('@ChillMain/Workflow/workflow_notification_on_transition_completed_content.fr.txt.twig', $context)) ->addAddressee($subscriber) - ->setType(NotificationEnum::WORKFLOW_TRANS); + ->setType(NotificationFlagEnum::WORKFLOW_TRANS); $this->entityManager->persist($notification); } } diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 9ef3ce161..fd719374f 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -719,7 +719,7 @@ notification: flags: type: Type de notification referrer-acc-course: Notification lors de la désignation comme référent - acc-course-work-eval: Notification sur un document d'évaluation + acc-course-work-eval-doc: Notification sur un document d'évaluation acc-course-work: Notification sur un action d'accompagnement activity: Notification sur un échange acc-course: Notification sur un parcours d'accompagnement diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php index a5135971f..b5c3f988b 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/PersonAddressMoveEventSubscriber.php @@ -13,7 +13,7 @@ namespace Chill\PersonBundle\AccompanyingPeriod\Events; use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Entity\Notification; -use Chill\MainBundle\Entity\NotificationEnum; +use Chill\MainBundle\Entity\NotificationFlagEnum; use Chill\MainBundle\Notification\NotificationPersisterInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Event\Person\PersonAddressMoveEvent; @@ -67,7 +67,7 @@ class PersonAddressMoveEventSubscriber implements EventSubscriberInterface 'oldPersonLocation' => $person, 'period' => $period, ])) - ->setType(NotificationEnum::PERSON_MOVE); + ->setType(NotificationFlagEnum::PERSON_MOVE); $this->notificationPersister->persist($notification); } diff --git a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php index e99bb44b5..f2f4d677c 100644 --- a/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php +++ b/src/Bundle/ChillPersonBundle/AccompanyingPeriod/Events/UserRefEventSubscriber.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\AccompanyingPeriod\Events; use Chill\MainBundle\Entity\Notification; -use Chill\MainBundle\Entity\NotificationEnum; +use Chill\MainBundle\Entity\NotificationFlagEnum; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Notification\NotificationPersisterInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; @@ -75,7 +75,7 @@ class UserRefEventSubscriber implements EventSubscriberInterface ] )) ->addAddressee($period->getUser()) - ->setType(NotificationEnum::REFERRER_ACC_COURSE); + ->setType(NotificationFlagEnum::REFERRER_ACC_COURSE); $this->notificationPersister->persist($notification); }