diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/EntryRepository.php | 22 |
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 | /** |