]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/WallabagBundle/Repository/EntriesRepository.php
some parameters, new entry form, etc.
[github/wallabag/wallabag.git] / src / WallabagBundle / Repository / EntriesRepository.php
index c4428a1d20046e6cf70d1d45c33a020716429cf7..3eb1733d1ebff98cb3ea92c19fa6093155b7f184 100644 (file)
@@ -8,6 +8,14 @@ use Doctrine\ORM\Tools\Pagination\Paginator;
 
 class EntriesRepository extends EntityRepository
 {
+    /**
+     * Retrieves unread entries for a user
+     *
+     * @param $userId
+     * @param $firstResult
+     * @param int $maxResults
+     * @return Paginator
+     */
     public function findUnreadByUser($userId, $firstResult, $maxResults = 12)
     {
         $qb = $this->createQueryBuilder('e')
@@ -18,11 +26,19 @@ class EntriesRepository extends EntityRepository
             ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
             ->getQuery();
 
-        $pag = new Paginator($qb);
+        $paginator = new Paginator($qb);
 
-        return $pag;
+        return $paginator;
     }
 
+    /**
+     * Retrieves read entries for a user
+     *
+     * @param $userId
+     * @param $firstResult
+     * @param int $maxResults
+     * @return Paginator
+     */
     public function findArchiveByUser($userId, $firstResult, $maxResults = 12)
     {
         $qb = $this->createQueryBuilder('e')
@@ -31,12 +47,21 @@ class EntriesRepository extends EntityRepository
             ->setMaxResults($maxResults)
             ->where('e.isRead = 1')
             ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
-            ->getQuery()
-            ->getResult(Query::HYDRATE_ARRAY);
+            ->getQuery();
+
+        $paginator = new Paginator($qb);
 
-        return $qb;
+        return $paginator;
     }
 
+    /**
+     * Retrieves starred entries for a user
+     *
+     * @param $userId
+     * @param $firstResult
+     * @param int $maxResults
+     * @return Paginator
+     */
     public function findStarredByUser($userId, $firstResult, $maxResults = 12)
     {
         $qb = $this->createQueryBuilder('e')
@@ -45,9 +70,10 @@ class EntriesRepository extends EntityRepository
             ->setMaxResults($maxResults)
             ->where('e.isFav = 1')
             ->andWhere('e.userId =:userId')->setParameter('userId', $userId)
-            ->getQuery()
-            ->getResult(Query::HYDRATE_ARRAY);
+            ->getQuery();
+
+        $paginator = new Paginator($qb);
 
-        return $qb;
+        return $paginator;
     }
 }