diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationController.php b/src/Bundle/ChillMainBundle/Controller/NotificationController.php index 1580b1fa0..0bcd227b3 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationController.php @@ -11,8 +11,10 @@ declare(strict_types=1); namespace Chill\MainBundle\Controller; +use Chill\ActivityBundle\Entity\Activity; use Chill\MainBundle\Entity\Notification; use Chill\MainBundle\Entity\NotificationComment; +use Chill\MainBundle\Entity\NotificationEnum; use Chill\MainBundle\Form\NotificationCommentType; use Chill\MainBundle\Form\NotificationType; use Chill\MainBundle\Notification\Exception\NotificationHandlerNotFound; @@ -22,6 +24,9 @@ use Chill\MainBundle\Repository\NotificationRepository; use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Security\Authorization\NotificationVoter; use Chill\MainBundle\Security\ChillSecurity; +use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; +use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -53,11 +58,29 @@ class NotificationController extends AbstractController throw new BadRequestHttpException('missing entityId parameter'); } + $notificationType = ''; + + switch ($request->query->get('entityClass')) { + case Activity::class: + $notificationType = NotificationEnum::ACTIVITY; + break; + case AccompanyingPeriod::class: + $notificationType = NotificationEnum::ACC_COURSE; + break; + case AccompanyingPeriodWork::class: + $notificationType = NotificationEnum::ACC_COURSE_WORK; + break; + case AccompanyingPeriodWorkEvaluation::class: + $notificationType = NotificationEnum::ACC_COURSE_WORK_EVAL; + break; + } + $notification = new Notification(); $notification ->setRelatedEntityClass($request->query->get('entityClass')) ->setRelatedEntityId($request->query->getInt('entityId')) - ->setSender($this->security->getUser()); + ->setSender($this->security->getUser()) + ->setType($notificationType); $tos = $request->query->all('tos'); diff --git a/src/Bundle/ChillMainBundle/Entity/NotificationEnum.php b/src/Bundle/ChillMainBundle/Entity/NotificationEnum.php index ead6805e9..a320b4ee4 100644 --- a/src/Bundle/ChillMainBundle/Entity/NotificationEnum.php +++ b/src/Bundle/ChillMainBundle/Entity/NotificationEnum.php @@ -15,10 +15,9 @@ enum NotificationEnum: string { case REFERRER_ACC_COURSE = 'referrer-acc-course-notif'; case PERSON_MOVE = 'person-move-notif'; - case ACC_COURSE_USER = 'acc-course-user-notif'; - case PERSON_USER = 'person-user-notif'; + case ACC_COURSE = 'acc-course-notif'; case WORKFLOW_TRANS = 'workflow-trans-notif'; case ACC_COURSE_WORK = 'acc-course-work-notif'; case ACC_COURSE_WORK_EVAL = 'acc-course-work-eval-notif'; - case ACTIVITY_USER = 'activity-user-notif'; + case ACTIVITY = 'activity-notif'; }