]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Repository/NotificationRepository.php
Notifications
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / NotificationRepository.php
diff --git a/src/Wallabag/CoreBundle/Repository/NotificationRepository.php b/src/Wallabag/CoreBundle/Repository/NotificationRepository.php
new file mode 100644 (file)
index 0000000..6d6938a
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+
+namespace Wallabag\CoreBundle\Repository;
+
+use Doctrine\ORM\EntityRepository;
+
+class NotificationRepository extends EntityRepository
+{
+    public function markAllAsReadForUser($userId)
+    {
+        return $this->getEntityManager()->createQueryBuilder()
+        ->update('WallabagCoreBundle:Notification', 'n')
+        ->set('n.read', true)
+        ->where('n.user = :userId')->setParameter('userId', $userId)
+        ->getQuery()
+        ->getResult();
+    }
+
+    public function getBuilderForNotificationsByUser($userId)
+    {
+        return $this->createQueryBuilder('n')
+            ->andWhere('n.user = :userId')->setParameter('userId', $userId)
+            ->orderBy('n.timestamp', 'desc')
+            ;
+    }
+}