aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Repository/EntryRepository.php
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-06-25 16:27:38 +0200
committerThomas Citharel <tcit@tcit.fr>2016-06-29 09:55:57 +0200
commit28803f106bd091b5a7540a134cba2545d12d25ea (patch)
tree111ef5e6252e4808f00c21cd8cc7b4813a1a22ff /src/Wallabag/CoreBundle/Repository/EntryRepository.php
parenta314b920bf20feedbeee6ce0432be89901091481 (diff)
downloadwallabag-28803f106bd091b5a7540a134cba2545d12d25ea.tar.gz
wallabag-28803f106bd091b5a7540a134cba2545d12d25ea.tar.zst
wallabag-28803f106bd091b5a7540a134cba2545d12d25ea.zip
Add filter for tags on API
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php')
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 4b607c81..8d2ec9ce 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -95,9 +95,10 @@ class EntryRepository extends EntityRepository
95 * 95 *
96 * @return array 96 * @return array
97 */ 97 */
98 public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC', $since = 0) 98 public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC', $since = 0, $tags = '')
99 { 99 {
100 $qb = $this->createQueryBuilder('e') 100 $qb = $this->createQueryBuilder('e')
101 ->leftJoin('e.tags', 't')
101 ->where('e.user =:userId')->setParameter('userId', $userId); 102 ->where('e.user =:userId')->setParameter('userId', $userId);
102 103
103 if (null !== $isArchived) { 104 if (null !== $isArchived) {
@@ -110,6 +111,11 @@ class EntryRepository extends EntityRepository
110 111
111 if ($since >= 0) { 112 if ($since >= 0) {
112 $qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since))); 113 $qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since)));
114
115 if ('' !== $tags) {
116 foreach (explode(',', $tags) as $tag) {
117 $qb->andWhere('t.label = :label')->setParameter('label', $tag);
118 }
113 } 119 }
114 120
115 if ('created' === $sort) { 121 if ('created' === $sort) {