mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-04 20:39:40 +00:00
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:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user