[ 'onStateEntered', ], ]; } public function onStateEntered(EnteredEvent $enteredEvent): void { if ( $enteredEvent->getMarking()->has(AccompanyingPeriod::STEP_CONFIRMED) and 'confirm' === $enteredEvent->getTransition()->getName() ) { $this->onPeriodConfirmed($enteredEvent->getSubject()); } } public function postUpdate(AccompanyingPeriod $period, LifecycleEventArgs $args): void { if ($period->isChangedUser() && $period->getUser() !== $this->security->getUser() && null !== $period->getUser() && AccompanyingPeriod::STEP_DRAFT !== $period->getStep() && !$period->isPreventUserIsChangedNotification() ) { $this->generateNotificationToUser($period); } } private function generateNotificationToUser(AccompanyingPeriod $period) { $notification = new Notification(); $urgentStatement = $period->isEmergency() ? strtoupper($this->translator->trans('accompanying_period.emergency')).' ' : ''; $notification ->setRelatedEntityId($period->getId()) ->setRelatedEntityClass(AccompanyingPeriod::class) ->setTitle($urgentStatement.$this->translator->trans('period_notification.period_designated_subject')) ->setMessage($this->engine->render( '@ChillPerson/Notification/accompanying_course_designation.md.twig', [ 'accompanyingCourse' => $period, ] )) ->addAddressee($period->getUser()) ->setType(NotificationFlagEnum::REFERRER_ACC_COURSE); $this->notificationPersister->persist($notification); } private function onPeriodConfirmed(AccompanyingPeriod $period) { if ($period->getUser() instanceof User && $period->getUser() !== $this->security->getUser()) { $this->generateNotificationToUser($period); } } }