aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Repository/EntryRepository.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-11-10 15:23:53 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2016-11-19 19:17:30 +0100
commit49b042dfdf33a0efd3c838e1476754e6019730d2 (patch)
tree6db14479ee9573cfdc44d435c0cc6d56bdae0c74 /src/Wallabag/CoreBundle/Repository/EntryRepository.php
parent398de40517356981a9fe1b9185f5f9e5e498c346 (diff)
downloadwallabag-49b042dfdf33a0efd3c838e1476754e6019730d2.tar.gz
wallabag-49b042dfdf33a0efd3c838e1476754e6019730d2.tar.zst
wallabag-49b042dfdf33a0efd3c838e1476754e6019730d2.zip
Added translations and currentRoute parameter
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php')
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 8f23164f..51cfe4d1 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -90,18 +90,30 @@ class EntryRepository extends EntityRepository
90 * 90 *
91 * @param int $userId 91 * @param int $userId
92 * @param string $term 92 * @param string $term
93 * @param strint $currentRoute
93 * 94 *
94 * @return QueryBuilder 95 * @return QueryBuilder
95 */ 96 */
96 public function getBuilderForSearchByUser($userId, $term) 97 public function getBuilderForSearchByUser($userId, $term, $currentRoute)
97 { 98 {
98 return $this 99 $qb = $this
99 ->getBuilderByUser($userId) 100 ->getBuilderByUser($userId);
100 ->andWhere('e.content LIKE :term')->setParameter('term', '%'.$term.'%') 101
101 ->orWhere('e.title LIKE :term')->setParameter('term', '%'.$term.'%') 102 if ('starred' === $currentRoute) {
103 $qb->andWhere('e.isStarred = true');
104 } elseif ('unread' === $currentRoute) {
105 $qb->andWhere('e.isArchived = false');
106 } elseif ('archive' === $currentRoute) {
107 $qb->andWhere('e.isArchived = true');
108 }
109
110 $qb
111 ->andWhere('e.content LIKE :term OR e.title LIKE :term')->setParameter('term', '%'.$term.'%')
102 ->leftJoin('e.tags', 't') 112 ->leftJoin('e.tags', 't')
103 ->groupBy('e.id') 113 ->groupBy('e.id')
104 ->having('count(t.id) = 0'); 114 ->having('count(t.id) = 0');
115
116 return $qb;
105 } 117 }
106 118
107 /** 119 /**