aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas@loeuillet.org>2015-02-05 07:54:04 +0100
committerNicolas Lœuillet <nicolas@loeuillet.org>2015-02-05 07:54:04 +0100
commitbc782eaa72e554ef7e5dd2662d0b5f22a19da0ef (patch)
tree33983e0b4f8679b2ff660f108ce455bc73987632
parent34d15eb4d0544263d27650207b23bd046e509f74 (diff)
downloadwallabag-bc782eaa72e554ef7e5dd2662d0b5f22a19da0ef.tar.gz
wallabag-bc782eaa72e554ef7e5dd2662d0b5f22a19da0ef.tar.zst
wallabag-bc782eaa72e554ef7e5dd2662d0b5f22a19da0ef.zip
sort entries in repository
-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);