getMessage()); } else { throw $e; } } public function findBySubscriptionId(int $subscriptionId): ?WebPushSubscription { try { return $this->mapper->findBySubscriptionId($subscriptionId); } catch (Exception $e) { $this->handleException($e); } } public function findByPushResource(string $userId, string $collectionName, string $pushResource): ?WebPushSubscription { try { return $this->mapper->findByPushResource($userId, $collectionName, $pushResource); } catch (Exception $e) { $this->handleException($e); } } public function create(int $subscriptionId, string $pushResource): WebPushSubscription { $webPushSubscription = new WebPushSubscription(); $webPushSubscription->setSubscriptionId($subscriptionId); $webPushSubscription->setPushResource($pushResource); $webPushSubscription = $this->mapper->insert($webPushSubscription); return $webPushSubscription; } public function deleteBySubscriptionId(int $subscriptionId): ?WebPushSubscription { try { $webPushSubscription = $this->mapper->findBySubscriptionId($subscriptionId); $this->mapper->delete($webPushSubscription); return $webPushSubscription; } catch (Exception $e) { $this->handleException($e); } } }