X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FRepository%2FEntryRepository.php;h=51cfe4d195447be7e87b696ee3b394dba78ca824;hb=49b042dfdf33a0efd3c838e1476754e6019730d2;hp=8f23164f7458c67efacc21da1808831d879f197c;hpb=398de40517356981a9fe1b9185f5f9e5e498c346;p=github%2Fwallabag%2Fwallabag.git 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 * * @param int $userId * @param string $term + * @param strint $currentRoute * * @return QueryBuilder */ - public function getBuilderForSearchByUser($userId, $term) + public function getBuilderForSearchByUser($userId, $term, $currentRoute) { - return $this - ->getBuilderByUser($userId) - ->andWhere('e.content LIKE :term')->setParameter('term', '%'.$term.'%') - ->orWhere('e.title LIKE :term')->setParameter('term', '%'.$term.'%') + $qb = $this + ->getBuilderByUser($userId); + + if ('starred' === $currentRoute) { + $qb->andWhere('e.isStarred = true'); + } elseif ('unread' === $currentRoute) { + $qb->andWhere('e.isArchived = false'); + } elseif ('archive' === $currentRoute) { + $qb->andWhere('e.isArchived = true'); + } + + $qb + ->andWhere('e.content LIKE :term OR e.title LIKE :term')->setParameter('term', '%'.$term.'%') ->leftJoin('e.tags', 't') ->groupBy('e.id') ->having('count(t.id) = 0'); + + return $qb; } /**