From ff25ab2f91bb4109fb4d2c80bfa670f8ead43b2f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 8 Aug 2025 15:53:34 +0200 Subject: [PATCH] feat: add task notification handler - WIP Implement `TaskNotificationHandler` for generating task-related notifications - Created `showInNotification.html.twig` for rendering task notification view - Added logic to fetch and display task data in notifications --- .../Notification/TaskNotificationHandler.php | 68 +++++++++++++++++++ .../SingleTask/showInNotification.html.twig | 17 +++++ 2 files changed, 85 insertions(+) create mode 100644 src/Bundle/ChillTaskBundle/Notification/TaskNotificationHandler.php create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showInNotification.html.twig diff --git a/src/Bundle/ChillTaskBundle/Notification/TaskNotificationHandler.php b/src/Bundle/ChillTaskBundle/Notification/TaskNotificationHandler.php new file mode 100644 index 000000000..1bb434fcc --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Notification/TaskNotificationHandler.php @@ -0,0 +1,68 @@ + $notification, + 'task' => $this->repository->find($notification->getRelatedEntityId()), + ]; + } + + public function supports(Notification $notification, array $options = []): bool + { + return SingleTask::class === $notification->getRelatedEntityClass(); + } + + public function getTitle(Notification $notification, array $options = []): TranslatableInterface + { + if (null === $task = $this->getRelatedEntity($notification)) { + return new TranslatableMessage('task.deleted'); + } + + return new TranslatableMessage('task.title', ['id' => $task->getId()]); + } + + public function getAssociatedPersons(Notification $notification, array $options = []): array + { + if (null === $task = $this->getRelatedEntity($notification)) { + return []; + } + + return $task->get; + } + + public function getRelatedEntity(Notification $notification): ?AccompanyingPeriod + { + return $this->accompanyingPeriodRepository->find($notification->getRelatedEntityId()); + } +} diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showInNotification.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showInNotification.html.twig new file mode 100644 index 000000000..8cd4a7d05 --- /dev/null +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/showInNotification.html.twig @@ -0,0 +1,17 @@ +{% macro recordAction(task) %} +
  • + +
  • +{% endmacro %} + +{% if task is not null %} +
    + {# TODO task item #} +

    Some task

    +
    +{% else %} +
    + {{ 'You are getting a notification for a task which does not exist any more'|trans }} +
    +{% endif %}