aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorJeremy <j0k3r@users.noreply.github.com>2015-02-05 19:06:48 +0100
committerJeremy <j0k3r@users.noreply.github.com>2015-02-05 19:06:48 +0100
commitde00c9208dddb7166eccdbf58fca1fafd9c7b392 (patch)
tree6cfdc518c969a02e4a4ef0e09eb1490afbcbebff /src/Wallabag
parent3bb7c5ffeceac653b014aa515ed7e50cfe25c392 (diff)
parentbc782eaa72e554ef7e5dd2662d0b5f22a19da0ef (diff)
downloadwallabag-de00c9208dddb7166eccdbf58fca1fafd9c7b392.tar.gz
wallabag-de00c9208dddb7166eccdbf58fca1fafd9c7b392.tar.zst
wallabag-de00c9208dddb7166eccdbf58fca1fafd9c7b392.zip
Merge pull request #1048 from wallabag/v2-sort-entries
sort entries in repository
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntriesRepository.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntriesRepository.php b/src/Wallabag/CoreBundle/Repository/EntriesRepository.php
index dd92d520..ae854e5a 100644
--- a/src/Wallabag/CoreBundle/Repository/EntriesRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntriesRepository.php
@@ -26,6 +26,7 @@ class EntriesRepository extends EntityRepository
26 ->where('e.isRead = 0') 26 ->where('e.isRead = 0')
27 ->andWhere('e.userId =:userId')->setParameter('userId', $userId) 27 ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
28 ->andWhere('e.isDeleted=0') 28 ->andWhere('e.isDeleted=0')
29 ->orderBy('e.createdAt', 'desc')
29 ->getQuery(); 30 ->getQuery();
30 31
31 $paginator = new Paginator($qb); 32 $paginator = new Paginator($qb);
@@ -50,6 +51,7 @@ class EntriesRepository extends EntityRepository
50 ->where('e.isRead = 1') 51 ->where('e.isRead = 1')
51 ->andWhere('e.userId =:userId')->setParameter('userId', $userId) 52 ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
52 ->andWhere('e.isDeleted=0') 53 ->andWhere('e.isDeleted=0')
54 ->orderBy('e.createdAt', 'desc')
53 ->getQuery(); 55 ->getQuery();
54 56
55 $paginator = new Paginator($qb); 57 $paginator = new Paginator($qb);
@@ -74,6 +76,7 @@ class EntriesRepository extends EntityRepository
74 ->where('e.isFav = 1') 76 ->where('e.isFav = 1')
75 ->andWhere('e.userId =:userId')->setParameter('userId', $userId) 77 ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
76 ->andWhere('e.isDeleted=0') 78 ->andWhere('e.isDeleted=0')
79 ->orderBy('e.createdAt', 'desc')
77 ->getQuery(); 80 ->getQuery();
78 81
79 $paginator = new Paginator($qb); 82 $paginator = new Paginator($qb);
@@ -83,7 +86,6 @@ class EntriesRepository extends EntityRepository
83 86
84 public function findEntries($userId, $isArchived, $isStarred, $isDeleted, $sort, $order) 87 public function findEntries($userId, $isArchived, $isStarred, $isDeleted, $sort, $order)
85 { 88 {
86 //TODO tous les paramètres ne sont pas utilisés, à corriger
87 $qb = $this->createQueryBuilder('e') 89 $qb = $this->createQueryBuilder('e')
88 ->select('e') 90 ->select('e')
89 ->where('e.userId =:userId')->setParameter('userId', $userId); 91 ->where('e.userId =:userId')->setParameter('userId', $userId);
@@ -100,6 +102,12 @@ class EntriesRepository extends EntityRepository
100 $qb->andWhere('e.isDeleted =:isDeleted')->setParameter('isDeleted', $isDeleted); 102 $qb->andWhere('e.isDeleted =:isDeleted')->setParameter('isDeleted', $isDeleted);
101 } 103 }
102 104
105 if ('created' === $sort) {
106 $qb->orderBy('e.createdAt', $order);
107 } elseif ('updated' === $sort) {
108 $qb->orderBy('e.updatedAt', $order);
109 }
110
103 return $qb 111 return $qb
104 ->getQuery() 112 ->getQuery()
105 ->getResult(Query::HYDRATE_ARRAY); 113 ->getResult(Query::HYDRATE_ARRAY);