diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-11-19 20:42:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-19 20:42:27 +0100 |
commit | 6f85bed294d6dd9f2dd9c945544074cbde38e191 (patch) | |
tree | 1ac2c526e54ddaf1678184f93d4e10a7a015349c /src/Wallabag/CoreBundle/Repository/EntryRepository.php | |
parent | 27dce581caba158a8ffffa5bc30648a21f47da12 (diff) | |
parent | 995c204428dd6be04d2bff1d5e17f3e95268f44d (diff) | |
download | wallabag-6f85bed294d6dd9f2dd9c945544074cbde38e191.tar.gz wallabag-6f85bed294d6dd9f2dd9c945544074cbde38e191.tar.zst wallabag-6f85bed294d6dd9f2dd9c945544074cbde38e191.zip |
Merge pull request #2543 from wallabag/search-engine
Added a simple search engine
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/EntryRepository.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 61be5220..47e24d6b 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php | |||
@@ -86,6 +86,36 @@ class EntryRepository extends EntityRepository | |||
86 | } | 86 | } |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Retrieves entries filtered with a search term for a user. | ||
90 | * | ||
91 | * @param int $userId | ||
92 | * @param string $term | ||
93 | * @param strint $currentRoute | ||
94 | * | ||
95 | * @return QueryBuilder | ||
96 | */ | ||
97 | public function getBuilderForSearchByUser($userId, $term, $currentRoute) | ||
98 | { | ||
99 | $qb = $this | ||
100 | ->getBuilderByUser($userId); | ||
101 | |||
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.'%') | ||
112 | ->leftJoin('e.tags', 't') | ||
113 | ->groupBy('e.id'); | ||
114 | |||
115 | return $qb; | ||
116 | } | ||
117 | |||
118 | /** | ||
89 | * Retrieves untagged entries for a user. | 119 | * Retrieves untagged entries for a user. |
90 | * | 120 | * |
91 | * @param int $userId | 121 | * @param int $userId |