]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Repository/EntriesRepository.php
for GET /api/entries, star, delete and archive status are no more necessary
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / EntriesRepository.php
index c76b421569433909279c79d2f5fa1e0444472a36..aaca4251440eb84002781594738ccb366cfc45ef 100644 (file)
@@ -86,13 +86,19 @@ class EntriesRepository extends EntityRepository
         //TODO tous les paramètres ne sont pas utilisés, à corriger
         $qb = $this->createQueryBuilder('e')
             ->select('e')
-            ->where('e.isFav =:isStarred')->setParameter('isStarred', $isStarred)
-            ->andWhere('e.isRead =:isArchived')->setParameter('isArchived', $isArchived)
-            ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
-            ->andWhere('e.isDeleted=0')
+            ->where('e.userId =:userId')->setParameter('userId', $userId)
+            ->andWhere('e.isDeleted=0');
+
+        if (!is_null($isArchived)) {
+            $qb->andWhere('e.isRead =:isArchived')->setParameter('isArchived', $isArchived);
+        }
+
+        if (!is_null($isStarred)) {
+            $qb->andWhere('e.isFav =:isStarred')->setParameter('isStarred', $isStarred);
+        }
+
+        return $qb
             ->getQuery()
             ->getResult(Query::HYDRATE_ARRAY);
-
-        return $qb;
     }
 }