Use enums in flag providers and rename NotificationEnum to NotificationFlagEnum

This commit is contained in:
Julie Lenaerts 2025-06-18 15:24:12 +02:00
parent acad9d1553
commit cf391d60fe
14 changed files with 35 additions and 28 deletions

View File

@ -14,7 +14,7 @@ namespace Chill\MainBundle\Controller;
use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\Activity;
use Chill\MainBundle\Entity\Notification; use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Entity\NotificationComment; use Chill\MainBundle\Entity\NotificationComment;
use Chill\MainBundle\Entity\NotificationEnum; use Chill\MainBundle\Entity\NotificationFlagEnum;
use Chill\MainBundle\Form\NotificationCommentType; use Chill\MainBundle\Form\NotificationCommentType;
use Chill\MainBundle\Form\NotificationType; use Chill\MainBundle\Form\NotificationType;
use Chill\MainBundle\Notification\Exception\NotificationHandlerNotFound; use Chill\MainBundle\Notification\Exception\NotificationHandlerNotFound;
@ -62,16 +62,16 @@ class NotificationController extends AbstractController
switch ($request->query->get('entityClass')) { switch ($request->query->get('entityClass')) {
case Activity::class: case Activity::class:
$notificationType = NotificationEnum::ACTIVITY; $notificationType = NotificationFlagEnum::ACTIVITY;
break; break;
case AccompanyingPeriod::class: case AccompanyingPeriod::class:
$notificationType = NotificationEnum::ACC_COURSE; $notificationType = NotificationFlagEnum::ACC_COURSE;
break; break;
case AccompanyingPeriodWork::class: case AccompanyingPeriodWork::class:
$notificationType = NotificationEnum::ACC_COURSE_WORK; $notificationType = NotificationFlagEnum::ACC_COURSE_WORK;
break; break;
case AccompanyingPeriodWorkEvaluation::class: case AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument::class:
$notificationType = NotificationEnum::ACC_COURSE_WORK_EVAL; $notificationType = NotificationFlagEnum::ACC_COURSE_WORK_EVAL_DOC;
break; break;
} }

View File

@ -101,8 +101,8 @@ class Notification implements TrackUpdateInterface
#[ORM\ManyToOne(targetEntity: User::class)] #[ORM\ManyToOne(targetEntity: User::class)]
private ?User $updatedBy = null; private ?User $updatedBy = null;
#[ORM\Column(name: 'type', type: Types::STRING, nullable: true, enumType: NotificationEnum::class)] #[ORM\Column(name: 'type', type: Types::STRING, nullable: true, enumType: NotificationFlagEnum::class)]
private NotificationEnum $type; private NotificationFlagEnum $type;
public function __construct() public function __construct()
{ {
@ -394,14 +394,14 @@ class Notification implements TrackUpdateInterface
return $this; return $this;
} }
public function setType(NotificationEnum $type): self public function setType(NotificationFlagEnum $type): self
{ {
$this->type = $type; $this->type = $type;
return $this; return $this;
} }
public function getType(): NotificationEnum public function getType(): NotificationFlagEnum
{ {
return $this->type; return $this->type;
} }

View File

@ -11,13 +11,13 @@ declare(strict_types=1);
namespace Chill\MainBundle\Entity; namespace Chill\MainBundle\Entity;
enum NotificationEnum: string enum NotificationFlagEnum: string
{ {
case REFERRER_ACC_COURSE = 'referrer-acc-course-notif'; case REFERRER_ACC_COURSE = 'referrer-acc-course-notif';
case PERSON_MOVE = 'person-move-notif'; case PERSON_MOVE = 'person-move-notif';
case ACC_COURSE = 'acc-course-notif'; case ACC_COURSE = 'acc-course-notif';
case WORKFLOW_TRANS = 'workflow-trans-notif'; case WORKFLOW_TRANS = 'workflow-trans-notif';
case ACC_COURSE_WORK = 'acc-course-work-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'; case ACTIVITY = 'activity-notif';
} }

View File

@ -2,6 +2,7 @@
namespace Chill\MainBundle\Notification\FlagProviders; namespace Chill\MainBundle\Notification\FlagProviders;
use Chill\MainBundle\Entity\NotificationFlagEnum;
use Symfony\Component\Translation\TranslatableMessage; use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface; use Symfony\Contracts\Translation\TranslatableInterface;
@ -10,7 +11,7 @@ class AccompanyingCourseNotificationFlagProvider implements NotificationFlagProv
public function getFlag(): string public function getFlag(): string
{ {
return 'acc-course-notif'; return NotificationFlagEnum::ACC_COURSE->value;
} }
public function getLabel(): TranslatableInterface public function getLabel(): TranslatableInterface

View File

@ -2,19 +2,20 @@
namespace Chill\MainBundle\Notification\FlagProviders; namespace Chill\MainBundle\Notification\FlagProviders;
use Chill\MainBundle\Entity\NotificationFlagEnum;
use Symfony\Component\Translation\TranslatableMessage; use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface; use Symfony\Contracts\Translation\TranslatableInterface;
class AccompanyingCourseWorkEvalNotificationFlagProvider implements NotificationFlagProviderInterface class AccompanyingCourseWorkEvalDocNotificationFlagProvider implements NotificationFlagProviderInterface
{ {
public function getFlag(): string public function getFlag(): string
{ {
return 'acc-course-work-eval-notif'; return NotificationFlagEnum::ACC_COURSE_WORK_EVAL_DOC->value;
} }
public function getLabel(): TranslatableInterface public function getLabel(): TranslatableInterface
{ {
return new TranslatableMessage('notification.flags.acc-course-work-eval'); return new TranslatableMessage('notification.flags.acc-course-work-eval-doc');
} }
} }

View File

@ -2,6 +2,7 @@
namespace Chill\MainBundle\Notification\FlagProviders; namespace Chill\MainBundle\Notification\FlagProviders;
use Chill\MainBundle\Entity\NotificationFlagEnum;
use Symfony\Component\Translation\TranslatableMessage; use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface; use Symfony\Contracts\Translation\TranslatableInterface;
@ -10,7 +11,7 @@ class AccompanyingCourseWorkNotificationFlagProvider implements NotificationFlag
public function getFlag(): string public function getFlag(): string
{ {
return 'acc-course-work-notif'; return NotificationFlagEnum::ACC_COURSE_WORK->value;
} }
public function getLabel(): TranslatableInterface public function getLabel(): TranslatableInterface

View File

@ -2,6 +2,7 @@
namespace Chill\MainBundle\Notification\FlagProviders; namespace Chill\MainBundle\Notification\FlagProviders;
use Chill\MainBundle\Entity\NotificationFlagEnum;
use Symfony\Component\Translation\TranslatableMessage; use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface; use Symfony\Contracts\Translation\TranslatableInterface;
@ -10,7 +11,7 @@ class ActivityNotificationFlagProvider implements NotificationFlagProviderInterf
public function getFlag(): string public function getFlag(): string
{ {
return 'activity-notif'; return NotificationFlagEnum::ACTIVITY->value;
} }
public function getLabel(): TranslatableInterface public function getLabel(): TranslatableInterface

View File

@ -2,6 +2,7 @@
namespace Chill\MainBundle\Notification\FlagProviders; namespace Chill\MainBundle\Notification\FlagProviders;
use Chill\MainBundle\Entity\NotificationFlagEnum;
use Symfony\Component\Translation\TranslatableMessage; use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface; use Symfony\Contracts\Translation\TranslatableInterface;
@ -10,7 +11,7 @@ class DesignatedReferrerNotificationFlagProvider implements NotificationFlagProv
public function getFlag(): string public function getFlag(): string
{ {
return 'referrer-acc-course-notif'; return NotificationFlagEnum::REFERRER_ACC_COURSE->value;
} }
public function getLabel(): TranslatableInterface public function getLabel(): TranslatableInterface

View File

@ -2,6 +2,7 @@
namespace Chill\MainBundle\Notification\FlagProviders; namespace Chill\MainBundle\Notification\FlagProviders;
use Chill\MainBundle\Entity\NotificationFlagEnum;
use Symfony\Component\Translation\TranslatableMessage; use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface; use Symfony\Contracts\Translation\TranslatableInterface;
@ -10,7 +11,7 @@ class PersonAddressMoveNotificationFlagProvider implements NotificationFlagProvi
public function getFlag(): string public function getFlag(): string
{ {
return 'person-address-move-notif'; return NotificationFlagEnum::PERSON_MOVE->value;
} }
public function getLabel(): TranslatableInterface public function getLabel(): TranslatableInterface

View File

@ -2,6 +2,7 @@
namespace Chill\MainBundle\Notification\FlagProviders; namespace Chill\MainBundle\Notification\FlagProviders;
use Chill\MainBundle\Entity\NotificationFlagEnum;
use Symfony\Component\Translation\TranslatableMessage; use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface; use Symfony\Contracts\Translation\TranslatableInterface;
@ -10,7 +11,7 @@ class WorkflowTransitionNotificationFlagProvider implements NotificationFlagProv
public function getFlag(): string public function getFlag(): string
{ {
return 'workflow-trans-notif'; return NotificationFlagEnum::WORKFLOW_TRANS->value;
} }
public function getLabel(): TranslatableInterface public function getLabel(): TranslatableInterface

View File

@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Workflow\EventSubscriber; namespace Chill\MainBundle\Workflow\EventSubscriber;
use Chill\MainBundle\Entity\Notification; use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Entity\NotificationEnum; use Chill\MainBundle\Entity\NotificationFlagEnum;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserGroup; use Chill\MainBundle\Entity\UserGroup;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow; 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)) ->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)) ->setMessage($this->engine->render('@ChillMain/Workflow/workflow_notification_on_transition_completed_content.fr.txt.twig', $context))
->addAddressee($subscriber) ->addAddressee($subscriber)
->setType(NotificationEnum::WORKFLOW_TRANS); ->setType(NotificationFlagEnum::WORKFLOW_TRANS);
$this->entityManager->persist($notification); $this->entityManager->persist($notification);
} }
} }

View File

@ -719,7 +719,7 @@ notification:
flags: flags:
type: Type de notification type: Type de notification
referrer-acc-course: Notification lors de la désignation comme référent 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 acc-course-work: Notification sur un action d'accompagnement
activity: Notification sur un échange activity: Notification sur un échange
acc-course: Notification sur un parcours d'accompagnement acc-course: Notification sur un parcours d'accompagnement

View File

@ -13,7 +13,7 @@ namespace Chill\PersonBundle\AccompanyingPeriod\Events;
use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Notification; use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Entity\NotificationEnum; use Chill\MainBundle\Entity\NotificationFlagEnum;
use Chill\MainBundle\Notification\NotificationPersisterInterface; use Chill\MainBundle\Notification\NotificationPersisterInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Event\Person\PersonAddressMoveEvent; use Chill\PersonBundle\Event\Person\PersonAddressMoveEvent;
@ -67,7 +67,7 @@ class PersonAddressMoveEventSubscriber implements EventSubscriberInterface
'oldPersonLocation' => $person, 'oldPersonLocation' => $person,
'period' => $period, 'period' => $period,
])) ]))
->setType(NotificationEnum::PERSON_MOVE); ->setType(NotificationFlagEnum::PERSON_MOVE);
$this->notificationPersister->persist($notification); $this->notificationPersister->persist($notification);
} }

View File

@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\AccompanyingPeriod\Events; namespace Chill\PersonBundle\AccompanyingPeriod\Events;
use Chill\MainBundle\Entity\Notification; use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Entity\NotificationEnum; use Chill\MainBundle\Entity\NotificationFlagEnum;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Notification\NotificationPersisterInterface; use Chill\MainBundle\Notification\NotificationPersisterInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
@ -75,7 +75,7 @@ class UserRefEventSubscriber implements EventSubscriberInterface
] ]
)) ))
->addAddressee($period->getUser()) ->addAddressee($period->getUser())
->setType(NotificationEnum::REFERRER_ACC_COURSE); ->setType(NotificationFlagEnum::REFERRER_ACC_COURSE);
$this->notificationPersister->persist($notification); $this->notificationPersister->persist($notification);
} }