]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Repository/TagRepository.php
Merge pull request #2301 from wallabag/fix-rss-feeds
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / TagRepository.php
index 0f362f79ebb0efdc37d4a9f2599e4100e24723e6..41f616079dd53f69032512adf6a1bfb176b98657 100644 (file)
@@ -6,18 +6,33 @@ use Doctrine\ORM\EntityRepository;
 
 class TagRepository extends EntityRepository
 {
-    public function findByEntries($entryId)
+    /**
+     * Find Tags.
+     *
+     * @param int $userId
+     *
+     * @return array
+     */
+    public function findAllTags($userId)
     {
-        $qb = $this->createQueryBuilder('t')
-            ->select('t')
-            ->leftJoin('t.id', 'u')
-            ->where('e.isStarred = true')
-            ->andWhere('u.id =:userId')->setParameter('userId', $userId)
-            ->orderBy('e.createdAt', 'desc')
-            ->getQuery();
-
-        $paginator = new Paginator($qb);
+        return $this->createQueryBuilder('t')
+            ->leftJoin('t.entries', 'e')
+            ->where('e.user = :userId')->setParameter('userId', $userId);
+    }
 
-        return $paginator;
+    /**
+     * Used only in test case to get a tag for our entry.
+     *
+     * @return Tag
+     */
+    public function findOneByEntryAndTagLabel($entry, $label)
+    {
+        return $this->createQueryBuilder('t')
+            ->leftJoin('t.entries', 'e')
+            ->where('e.id = :entryId')->setParameter('entryId', $entry->getId())
+            ->andWhere('t.label = :label')->setParameter('label', $label)
+            ->setMaxResults(1)
+            ->getQuery()
+            ->getSingleResult();
     }
 }