public function findNotificationsBySubscriber(UserInterface $user, $limit = 20)
 {
     $className = $this->getClassResolver()->resolveClassName('Notification\\Entity\\NotificationInterface');
     $criteria = ['user' => $user->getId()];
     $order = ['id' => 'desc'];
     $notifications = $this->getObjectManager()->getRepository($className)->findBy($criteria, $order, $limit);
     $collection = new ArrayCollection($notifications);
     return $this->persistentNotificationFilterChain->filter($collection);
 }
 public function unSubscribe(UserInterface $user, UuidInterface $object)
 {
     $className = $this->getClassResolver()->resolveClassName('Notification\\Entity\\SubscriptionInterface');
     $criteria = ['user' => $user->getId(), 'object' => $object->getId()];
     $subscription = $this->getObjectManager()->getRepository($className)->findOneBy($criteria);
     if (is_object($subscription)) {
         $this->objectManager->remove($subscription);
     }
 }