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 %}