Resolve "Afficher les noms des usagers et l'entité concerné par l'entité notifiée dans la liste des notifications"

This commit is contained in:
2025-01-23 11:34:16 +00:00
committed by Julien Fastré
parent 9e191f1b5b
commit 9a5fd67842
28 changed files with 267 additions and 33 deletions

View File

@@ -15,6 +15,8 @@ use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Notification\NotificationHandlerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface;
final readonly class AccompanyingPeriodNotificationHandler implements NotificationHandlerInterface
{
@@ -37,4 +39,27 @@ final readonly class AccompanyingPeriodNotificationHandler implements Notificati
{
return AccompanyingPeriod::class === $notification->getRelatedEntityClass();
}
public function getTitle(Notification $notification, array $options = []): TranslatableInterface
{
if (null === $period = $this->getRelatedEntity($notification)) {
return new TranslatableMessage('accompanying_period.deleted');
}
return new TranslatableMessage('periods.title', ['id' => $period->getId()]);
}
public function getAssociatedPersons(Notification $notification, array $options = []): array
{
if (null === $period = $this->getRelatedEntity($notification)) {
return [];
}
return $period->getParticipations()->getValues();
}
public function getRelatedEntity(Notification $notification): ?AccompanyingPeriod
{
return $this->accompanyingPeriodRepository->find($notification->getRelatedEntityId());
}
}

View File

@@ -15,6 +15,8 @@ use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Notification\NotificationHandlerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocumentRepository;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface;
final readonly class AccompanyingPeriodWorkEvaluationDocumentNotificationHandler implements NotificationHandlerInterface
{
@@ -38,4 +40,33 @@ final readonly class AccompanyingPeriodWorkEvaluationDocumentNotificationHandler
{
return AccompanyingPeriodWorkEvaluationDocument::class === $notification->getRelatedEntityClass();
}
public function getTitle(Notification $notification, array $options = []): TranslatableInterface
{
if (null === $eval = $this->getRelatedEntity($notification)) {
return new TranslatableMessage('evaluation.deleted');
}
return new TranslatableMessage(
'accompanying_course_evaluation_document.title',
[
'id' => $eval->getId(),
'doc_title' => $eval->getTitle(),
]
);
}
public function getAssociatedPersons(Notification $notification, array $options = []): array
{
if (null === $eval = $this->getRelatedEntity($notification)) {
return [];
}
return $eval->getAccompanyingPeriodWorkEvaluation()->getAccompanyingPeriodWork()->getPersons()->getValues();
}
public function getRelatedEntity(Notification $notification): ?AccompanyingPeriodWorkEvaluationDocument
{
return $this->accompanyingPeriodWorkEvaluationDocumentRepository->find($notification->getRelatedEntityId());
}
}

View File

@@ -13,12 +13,15 @@ namespace Chill\PersonBundle\Notification;
use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Notification\NotificationHandlerInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface;
final readonly class AccompanyingPeriodWorkNotificationHandler implements NotificationHandlerInterface
{
public function __construct(private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository) {}
public function __construct(private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository, private TranslatableStringHelperInterface $translatableStringHelper) {}
public function getTemplate(Notification $notification, array $options = []): string
{
@@ -37,4 +40,30 @@ final readonly class AccompanyingPeriodWorkNotificationHandler implements Notifi
{
return AccompanyingPeriodWork::class === $notification->getRelatedEntityClass();
}
public function getTitle(Notification $notification, array $options = []): TranslatableInterface
{
if (null === $work = $this->getRelatedEntity($notification)) {
return new TranslatableMessage('accompanying_course_work.deleted');
}
return new TranslatableMessage('accompanying_period_work.title', [
'id' => $work->getId(),
'action_title' => $this->translatableStringHelper->localize($work->getSocialAction()->getTitle()),
]);
}
public function getAssociatedPersons(Notification $notification, array $options = []): array
{
if (null === $work = $this->getRelatedEntity($notification)) {
return [];
}
return $work->getPersons()->getValues();
}
public function getRelatedEntity(Notification $notification): ?AccompanyingPeriodWork
{
return $this->accompanyingPeriodWorkRepository->find($notification->getRelatedEntityId());
}
}