Set type upon creation of notifications by user

This commit is contained in:
Julie Lenaerts 2025-06-18 14:48:06 +02:00
parent 0a19255a22
commit acad9d1553
2 changed files with 26 additions and 4 deletions

View File

@ -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');

View File

@ -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';
}