From ecb8ef0146fb4ea0b32731f10a03453d9c1ae24c Mon Sep 17 00:00:00 2001 From: Lucas Silva Date: Tue, 21 Mar 2023 14:34:38 +0100 Subject: [PATCH] add notification service for AccompanyingPeriodWork in show --- ...ompanyingPeriodWorkNotificationHandler.php | 46 +++++++++++++++++++ .../AccompanyingCourseWork/_item.html.twig | 7 +++ .../AccompanyingCourseWork/show.html.twig | 27 +++++++++-- .../showInNotification.html.twig | 28 +++++++++++ .../showInNotification.html.twig | 1 + .../config/services/notification.yaml | 3 ++ 6 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php new file mode 100644 index 000000000..dbb30e983 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php @@ -0,0 +1,46 @@ +accompanyingPeriodWorkRepository = $accompanyingPeriodWorkRepository; + } + + public function getTemplate(Notification $notification, array $options = []): string + { + return 'ChillPersonBundle:AccompanyingCourseWork:showInNotification.html.twig'; + } + + public function getTemplateData(Notification $notification, array $options = []): array + { + return [ + 'notification' => $notification, + 'work' => $this->accompanyingPeriodWorkRepository->find($notification->getRelatedEntityId()), + ]; + } + + public function supports(Notification $notification, array $options = []): bool + { + return $notification->getRelatedEntityClass() === AccompanyingPeriodWork::class; + } +} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig index 001ac1661..728554aaf 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig @@ -129,6 +129,13 @@ {% if displayAction is defined and displayAction == true %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig new file mode 100644 index 000000000..70a1a0980 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/showInNotification.html.twig @@ -0,0 +1,28 @@ +{% macro recordAction(work) %} +
  • + +
  • +{% endmacro %} +{% if work is not null %} +
    + {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', work) %} + {% else %} + {% endif %} + {% include 'ChillPersonBundle:AccompanyingCourseWork:_item.html.twig' with { + 'itemBlocClass': 'bg-chill-llight-gray', + 'displayAction': true, + 'displayContent': 'short', + 'displayFontSmall': true, + 'w': work + } %} +
    + {{ 'This is the minimal period details'|trans ~ ': ' ~ work.id }}
    + {{ 'You are getting a notification for a period you are not allowed to see'|trans }} +
    +
    +{% else %} +
    + {{ 'You are getting a notification for a period which does not exists any more'|trans }} +
    +{% endif %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/showInNotification.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/showInNotification.html.twig index 630dcf100..d6d13cd17 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/showInNotification.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/showInNotification.html.twig @@ -6,6 +6,7 @@ {% endmacro %} {% if period is not null %} + {{ dump(period) }}
    {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', period) %} {% include 'ChillPersonBundle:AccompanyingPeriod:_list_item.html.twig' with { diff --git a/src/Bundle/ChillPersonBundle/config/services/notification.yaml b/src/Bundle/ChillPersonBundle/config/services/notification.yaml index a7c9f4142..7fd64bfbf 100644 --- a/src/Bundle/ChillPersonBundle/config/services/notification.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/notification.yaml @@ -2,3 +2,6 @@ services: Chill\PersonBundle\Notification\AccompanyingPeriodNotificationHandler: autowire: true autoconfigure: true + Chill\PersonBundle\Notification\AccompanyingPeriodWorkNotificationHandler: + autowire: true + autoconfigure: true