*/ class NotificationApiController extends CommonApiController { public function __construct( CorePermissions $security, Translator $translator, EntityResultHelper $entityResultHelper, RouterInterface $router, FormFactoryInterface $formFactory, AppVersion $appVersion, protected ContactTracker $contactTracker, RequestStack $requestStack, ManagerRegistry $doctrine, ModelFactory $modelFactory, EventDispatcherInterface $dispatcher, CoreParametersHelper $coreParametersHelper, MauticFactory $factory ) { $notificationModel = $modelFactory->getModel('notification'); \assert($notificationModel instanceof NotificationModel); $this->model = $notificationModel; $this->entityClass = Notification::class; $this->entityNameOne = 'notification'; $this->entityNameMulti = 'notifications'; parent::__construct($security, $translator, $entityResultHelper, $router, $formFactory, $appVersion, $requestStack, $doctrine, $modelFactory, $dispatcher, $coreParametersHelper, $factory); } /** * Receive Web Push subscription request. */ public function subscribeAction(Request $request): JsonResponse { $osid = $request->get('osid'); if ($osid) { /** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */ $leadModel = $this->getModel('lead'); if ($currentLead = $this->contactTracker->getContact()) { $currentLead->addPushIDEntry($osid); $leadModel->saveEntity($currentLead); } return new JsonResponse(['success' => true, 'osid' => $osid], 200, ['Access-Control-Allow-Origin' => '*']); } return new JsonResponse(['success' => 'false'], 200, ['Access-Control-Allow-Origin' => '*']); } }