]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Repository/TagRepository.php
relation between tags and entries
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / TagRepository.php
index 005142fc568707a9b2e807f390dbf2cca8814fb2..0f362f79ebb0efdc37d4a9f2599e4100e24723e6 100644 (file)
@@ -3,77 +3,14 @@
 namespace Wallabag\CoreBundle\Repository;
 
 use Doctrine\ORM\EntityRepository;
-use Doctrine\ORM\Tools\Pagination\Paginator;
 
-class EntryRepository extends EntityRepository
+class TagRepository extends EntityRepository
 {
-    /**
-     * Retrieves unread entries for a user
-     *
-     * @param int $userId
-     * @param int $firstResult
-     * @param int $maxResults
-     *
-     * @return Paginator
-     */
-    public function findUnreadByUser($userId, $firstResult, $maxResults = 12)
+    public function findByEntries($entryId)
     {
-        $qb = $this->createQueryBuilder('e')
-            ->setFirstResult($firstResult)
-            ->setMaxResults($maxResults)
-            ->leftJoin('e.user', 'u')
-            ->where('e.isArchived = false')
-            ->andWhere('u.id =:userId')->setParameter('userId', $userId)
-            ->orderBy('e.createdAt', 'desc')
-            ->getQuery();
-
-        $paginator = new Paginator($qb);
-
-        return $paginator;
-    }
-
-    /**
-     * Retrieves read entries for a user
-     *
-     * @param int $userId
-     * @param int $firstResult
-     * @param int $maxResults
-     *
-     * @return Paginator
-     */
-    public function findArchiveByUser($userId, $firstResult, $maxResults = 12)
-    {
-        $qb = $this->createQueryBuilder('e')
-            ->select('e')
-            ->setFirstResult($firstResult)
-            ->setMaxResults($maxResults)
-            ->leftJoin('e.user', 'u')
-            ->where('e.isArchived = true')
-            ->andWhere('u.id =:userId')->setParameter('userId', $userId)
-            ->orderBy('e.createdAt', 'desc')
-            ->getQuery();
-
-        $paginator = new Paginator($qb);
-
-        return $paginator;
-    }
-
-    /**
-     * Retrieves starred entries for a user
-     *
-     * @param int $userId
-     * @param int $firstResult
-     * @param int $maxResults
-     *
-     * @return Paginator
-     */
-    public function findStarredByUser($userId, $firstResult, $maxResults = 12)
-    {
-        $qb = $this->createQueryBuilder('e')
-            ->select('e')
-            ->setFirstResult($firstResult)
-            ->setMaxResults($maxResults)
-            ->leftJoin('e.user', 'u')
+        $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')
@@ -83,39 +20,4 @@ class EntryRepository extends EntityRepository
 
         return $paginator;
     }
-
-    /**
-     * Find Entries
-     *
-     * @param int    $userId
-     * @param bool   $isArchived
-     * @param bool   $isStarred
-     * @param string $sort
-     * @param string $order
-     *
-     * @return array
-     */
-    public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC')
-    {
-        $qb = $this->createQueryBuilder('e')
-            ->where('e.user =:userId')->setParameter('userId', $userId);
-
-        if (null !== $isArchived) {
-            $qb->andWhere('e.isArchived =:isArchived')->setParameter('isArchived', (bool) $isArchived);
-        }
-
-        if (null !== $isStarred) {
-            $qb->andWhere('e.isStarred =:isStarred')->setParameter('isStarred', (bool) $isStarred);
-        }
-
-        if ('created' === $sort) {
-            $qb->orderBy('e.createdAt', $order);
-        } elseif ('updated' === $sort) {
-            $qb->orderBy('e.updatedAt', $order);
-        }
-
-        return $qb
-            ->getQuery()
-            ->getResult();
-    }
 }