]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Repository/EntryRepository.php
Start work on sort function.
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / EntryRepository.php
index bfd079377ac783bdd4c2e0e2f84cb3f2e9d0496b..92d1867bf7532e924185b54862b6710d86330249 100644 (file)
@@ -20,10 +20,10 @@ class EntryRepository extends EntityRepository
      *
      * @return QueryBuilder
      */
-    public function getBuilderForAllByUser($userId)
+    public function getBuilderForAllByUser($userId, $sortBy = 'id', $direction = 'DESC')
     {
         return $this
-            ->getSortedQueryBuilderByUser($userId)
+            ->getSortedQueryBuilderByUser($userId, $sortBy, $direction)
         ;
     }
 
@@ -34,11 +34,12 @@ class EntryRepository extends EntityRepository
      *
      * @return QueryBuilder
      */
-    public function getBuilderForUnreadByUser($userId)
+    public function getBuilderForUnreadByUser($userId, $sortBy = 'id', $direction = 'DESC')
     {
         return $this
             ->getSortedQueryBuilderByUser($userId)
             ->andWhere('e.isArchived = false')
+            ->orderBy('e.'.$sortBy, $direction)
         ;
     }
 
@@ -49,11 +50,12 @@ class EntryRepository extends EntityRepository
      *
      * @return QueryBuilder
      */
-    public function getBuilderForArchiveByUser($userId)
+    public function getBuilderForArchiveByUser($userId, $sortBy = 'id', $direction = 'DESC')
     {
         return $this
             ->getSortedQueryBuilderByUser($userId, 'archivedAt', 'desc')
             ->andWhere('e.isArchived = true')
+            ->orderBy('e.'.$sortBy, $direction)
         ;
     }
 
@@ -64,11 +66,12 @@ class EntryRepository extends EntityRepository
      *
      * @return QueryBuilder
      */
-    public function getBuilderForStarredByUser($userId)
+    public function getBuilderForStarredByUser($userId, $sortBy = 'id', $direction = 'DESC')
     {
         return $this
             ->getSortedQueryBuilderByUser($userId, 'starredAt', 'desc')
             ->andWhere('e.isStarred = true')
+            ->orderBy('e.'.$sortBy, $direction)
         ;
     }