]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Repository/EntryRepository.php
Add filter for tags on API
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / EntryRepository.php
index 4b607c81671cd749a52ff30a4a28bc4ff4b7118d..8d2ec9ce4f471d6f0f098dc7ec0558dbbbbe71fb 100644 (file)
@@ -95,9 +95,10 @@ class EntryRepository extends EntityRepository
      *
      * @return array
      */
-    public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC', $since = 0)
+    public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC', $since = 0, $tags = '')
     {
         $qb = $this->createQueryBuilder('e')
+            ->leftJoin('e.tags', 't')
             ->where('e.user =:userId')->setParameter('userId', $userId);
 
         if (null !== $isArchived) {
@@ -110,6 +111,11 @@ class EntryRepository extends EntityRepository
 
         if ($since >= 0) {
             $qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since)));
+            
+        if ('' !== $tags) {
+            foreach (explode(',', $tags) as $tag) {
+                $qb->andWhere('t.label = :label')->setParameter('label', $tag);
+            }
         }
 
         if ('created' === $sort) {