diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationController.php b/src/Bundle/ChillMainBundle/Controller/NotificationController.php index d876241a5..2e4948aa9 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationController.php @@ -11,10 +11,8 @@ 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\NotificationFlagEnum; use Chill\MainBundle\Form\NotificationCommentType; use Chill\MainBundle\Form\NotificationType; use Chill\MainBundle\Notification\Exception\NotificationHandlerNotFound; @@ -24,9 +22,6 @@ 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; @@ -58,29 +53,12 @@ class NotificationController extends AbstractController throw new BadRequestHttpException('missing entityId parameter'); } - $notificationType = ''; - - switch ($request->query->get('entityClass')) { - case Activity::class: - $notificationType = NotificationFlagEnum::ACTIVITY; - break; - case AccompanyingPeriod::class: - $notificationType = NotificationFlagEnum::ACC_COURSE; - break; - case AccompanyingPeriodWork::class: - $notificationType = NotificationFlagEnum::ACC_COURSE_WORK; - break; - case AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument::class: - $notificationType = NotificationFlagEnum::ACC_COURSE_WORK_EVAL_DOC; - break; - } - $notification = new Notification(); $notification ->setRelatedEntityClass($request->query->get('entityClass')) ->setRelatedEntityId($request->query->getInt('entityId')) ->setSender($this->security->getUser()) - ->setType($notificationType); + ->setType('notif-by-user'); $tos = $request->query->all('tos'); diff --git a/src/Bundle/ChillMainBundle/Entity/Notification.php b/src/Bundle/ChillMainBundle/Entity/Notification.php index 38b4b195e..87c5c95ed 100644 --- a/src/Bundle/ChillMainBundle/Entity/Notification.php +++ b/src/Bundle/ChillMainBundle/Entity/Notification.php @@ -110,8 +110,8 @@ class Notification implements TrackUpdateInterface #[ORM\ManyToOne(targetEntity: User::class)] private ?User $updatedBy = null; - #[ORM\Column(name: 'type', type: Types::STRING, nullable: true, enumType: NotificationFlagEnum::class)] - private NotificationFlagEnum $type; + #[ORM\Column(name: 'type', type: Types::STRING, nullable: true)] + private string $type; public function __construct() { @@ -455,14 +455,14 @@ class Notification implements TrackUpdateInterface return $this; } - public function setType(NotificationFlagEnum $type): self + public function setType(string $type): self { $this->type = $type; return $this; } - public function getType(): NotificationFlagEnum + public function getType(): string { return $this->type; } diff --git a/src/Bundle/ChillMainBundle/Entity/NotificationFlagEnum.php b/src/Bundle/ChillMainBundle/Entity/NotificationFlagEnum.php deleted file mode 100644 index 2ee4345d8..000000000 --- a/src/Bundle/ChillMainBundle/Entity/NotificationFlagEnum.php +++ /dev/null @@ -1,23 +0,0 @@ -has('immediate_email')) { $flagForm->get('immediate_email')->setData($immediateEmailChecked); @@ -45,6 +46,9 @@ final readonly class NotificationFlagDataMapper implements DataMapperInterface if ($flagForm->has('daily_email')) { $flagForm->get('daily_email')->setData($dailyEmailChecked); } + if ($flagForm->has('no_email')) { + $flagForm->get('no_email')->setData($noEmailChecked); + } } } } @@ -69,7 +73,7 @@ final readonly class NotificationFlagDataMapper implements DataMapperInterface $viewData[$flag][] = 'daily-email'; } - if (empty($viewData[$flag])) { + if ($flagForm['no_email']->getData()) { $viewData[$flag][] = 'no-email'; } } diff --git a/src/Bundle/ChillMainBundle/Form/Type/NotificationFlagsType.php b/src/Bundle/ChillMainBundle/Form/Type/NotificationFlagsType.php index 9c21b59d1..fb25c9ae0 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/NotificationFlagsType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/NotificationFlagsType.php @@ -43,13 +43,19 @@ class NotificationFlagsType extends AbstractType ->add('immediate_email', CheckboxType::class, [ 'label' => false, 'required' => false, - 'mapped' => false, // Keep this here for the individual checkboxes + 'mapped' => false, ]) ->add('daily_email', CheckboxType::class, [ 'label' => false, 'required' => false, - 'mapped' => false, // Keep this here for the individual checkboxes - ]); + 'mapped' => false, + ]) + ->add('no_email', CheckboxType::class, [ + 'label' => false, + 'required' => false, + 'mapped' => false, + ]) + ; } } diff --git a/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseNotificationFlagProvider.php b/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseNotificationFlagProvider.php deleted file mode 100644 index 50d72531a..000000000 --- a/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseNotificationFlagProvider.php +++ /dev/null @@ -1,21 +0,0 @@ -value; - } - - public function getLabel(): TranslatableInterface - { - return new TranslatableMessage('notification.flags.acc-course'); - } -} diff --git a/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkEvalDocNotificationFlagProvider.php b/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkEvalDocNotificationFlagProvider.php deleted file mode 100644 index 3e96f6361..000000000 --- a/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkEvalDocNotificationFlagProvider.php +++ /dev/null @@ -1,21 +0,0 @@ -value; - } - - public function getLabel(): TranslatableInterface - { - return new TranslatableMessage('notification.flags.acc-course-work-eval-doc'); - } -} diff --git a/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkNotificationFlagProvider.php b/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkNotificationFlagProvider.php deleted file mode 100644 index b71abf5d4..000000000 --- a/src/Bundle/ChillMainBundle/Notification/FlagProviders/AccompanyingCourseWorkNotificationFlagProvider.php +++ /dev/null @@ -1,21 +0,0 @@ -value; - } - - public function getLabel(): TranslatableInterface - { - return new TranslatableMessage('notification.flags.acc-course-work'); - } -} diff --git a/src/Bundle/ChillMainBundle/Notification/FlagProviders/DesignatedReferrerNotificationFlagProvider.php b/src/Bundle/ChillMainBundle/Notification/FlagProviders/DesignatedReferrerNotificationFlagProvider.php index 335d4339e..582cd231b 100644 --- a/src/Bundle/ChillMainBundle/Notification/FlagProviders/DesignatedReferrerNotificationFlagProvider.php +++ b/src/Bundle/ChillMainBundle/Notification/FlagProviders/DesignatedReferrerNotificationFlagProvider.php @@ -2,7 +2,6 @@ namespace Chill\MainBundle\Notification\FlagProviders; -use Chill\MainBundle\Entity\NotificationFlagEnum; use Symfony\Component\Translation\TranslatableMessage; use Symfony\Contracts\Translation\TranslatableInterface; @@ -11,7 +10,7 @@ class DesignatedReferrerNotificationFlagProvider implements NotificationFlagProv public function getFlag(): string { - return NotificationFlagEnum::REFERRER_ACC_COURSE->value; + return 'referrer-acc-course-notif'; } public function getLabel(): TranslatableInterface diff --git a/src/Bundle/ChillMainBundle/Notification/FlagProviders/ActivityNotificationFlagProvider.php b/src/Bundle/ChillMainBundle/Notification/FlagProviders/NotificationByUserFlagProvider.php similarity index 53% rename from src/Bundle/ChillMainBundle/Notification/FlagProviders/ActivityNotificationFlagProvider.php rename to src/Bundle/ChillMainBundle/Notification/FlagProviders/NotificationByUserFlagProvider.php index 78515d72d..9c29c062c 100644 --- a/src/Bundle/ChillMainBundle/Notification/FlagProviders/ActivityNotificationFlagProvider.php +++ b/src/Bundle/ChillMainBundle/Notification/FlagProviders/NotificationByUserFlagProvider.php @@ -2,20 +2,19 @@ namespace Chill\MainBundle\Notification\FlagProviders; -use Chill\MainBundle\Entity\NotificationFlagEnum; use Symfony\Component\Translation\TranslatableMessage; use Symfony\Contracts\Translation\TranslatableInterface; -class ActivityNotificationFlagProvider implements NotificationFlagProviderInterface +class NotificationByUserFlagProvider implements NotificationFlagProviderInterface { public function getFlag(): string { - return NotificationFlagEnum::ACTIVITY->value; + return 'notif-by-user'; } public function getLabel(): TranslatableInterface { - return new TranslatableMessage('notification.flags.activity'); + return new TranslatableMessage('notification.flags.by-user'); } } diff --git a/src/Bundle/ChillMainBundle/Notification/FlagProviders/PersonAddressMoveNotificationFlagProvider.php b/src/Bundle/ChillMainBundle/Notification/FlagProviders/PersonAddressMoveNotificationFlagProvider.php index 6f33fa427..5842681ea 100644 --- a/src/Bundle/ChillMainBundle/Notification/FlagProviders/PersonAddressMoveNotificationFlagProvider.php +++ b/src/Bundle/ChillMainBundle/Notification/FlagProviders/PersonAddressMoveNotificationFlagProvider.php @@ -2,7 +2,6 @@ namespace Chill\MainBundle\Notification\FlagProviders; -use Chill\MainBundle\Entity\NotificationFlagEnum; use Symfony\Component\Translation\TranslatableMessage; use Symfony\Contracts\Translation\TranslatableInterface; @@ -11,7 +10,7 @@ class PersonAddressMoveNotificationFlagProvider implements NotificationFlagProvi public function getFlag(): string { - return NotificationFlagEnum::PERSON_MOVE->value; + return 'person-move-notif'; } public function getLabel(): TranslatableInterface diff --git a/src/Bundle/ChillMainBundle/Notification/FlagProviders/WorkflowTransitionNotificationFlagProvider.php b/src/Bundle/ChillMainBundle/Notification/FlagProviders/WorkflowTransitionNotificationFlagProvider.php index 3e48c400c..a048c91a5 100644 --- a/src/Bundle/ChillMainBundle/Notification/FlagProviders/WorkflowTransitionNotificationFlagProvider.php +++ b/src/Bundle/ChillMainBundle/Notification/FlagProviders/WorkflowTransitionNotificationFlagProvider.php @@ -2,7 +2,6 @@ namespace Chill\MainBundle\Notification\FlagProviders; -use Chill\MainBundle\Entity\NotificationFlagEnum; use Symfony\Component\Translation\TranslatableMessage; use Symfony\Contracts\Translation\TranslatableInterface; @@ -11,7 +10,7 @@ class WorkflowTransitionNotificationFlagProvider implements NotificationFlagProv public function getFlag(): string { - return NotificationFlagEnum::WORKFLOW_TRANS->value; + return 'workflow-trans-notif'; } public function getLabel(): TranslatableInterface diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/profile.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/profile.html.twig index 4448cae54..7a432332c 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/profile.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/profile.html.twig @@ -52,6 +52,7 @@