]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Repository/EntryRepository.php
relation between tags and entries
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / EntryRepository.php
index abf01930d1d9c6dc14a7176b9963df99bf6962e6..f6f60c6fec2cab86ade3867033df0489ed7eff77 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace Wallabag\CoreBundle\Repository;
 
-use Doctrine\ORM\Query;
 use Doctrine\ORM\EntityRepository;
 use Doctrine\ORM\Tools\Pagination\Paginator;
 
@@ -25,7 +24,6 @@ class EntryRepository extends EntityRepository
             ->leftJoin('e.user', 'u')
             ->where('e.isArchived = false')
             ->andWhere('u.id =:userId')->setParameter('userId', $userId)
-            ->andWhere('e.isDeleted=false')
             ->orderBy('e.createdAt', 'desc')
             ->getQuery();
 
@@ -52,7 +50,6 @@ class EntryRepository extends EntityRepository
             ->leftJoin('e.user', 'u')
             ->where('e.isArchived = true')
             ->andWhere('u.id =:userId')->setParameter('userId', $userId)
-            ->andWhere('e.isDeleted=false')
             ->orderBy('e.createdAt', 'desc')
             ->getQuery();
 
@@ -79,7 +76,6 @@ class EntryRepository extends EntityRepository
             ->leftJoin('e.user', 'u')
             ->where('e.isStarred = true')
             ->andWhere('u.id =:userId')->setParameter('userId', $userId)
-            ->andWhere('e.isDeleted = false')
             ->orderBy('e.createdAt', 'desc')
             ->getQuery();
 
@@ -91,20 +87,18 @@ class EntryRepository extends EntityRepository
     /**
      * Find Entries
      *
-     * @param  int    $userId
-     * @param  bool   $isArchived
-     * @param  bool   $isStarred
-     * @param  bool   $isDeleted
-     * @param  string $sort
-     * @param  string $order
+     * @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, $isDeleted = null, $sort = 'created', $order = 'ASC')
+    public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC')
     {
         $qb = $this->createQueryBuilder('e')
-            ->leftJoin('e.user', 'u')
-            ->where('u.id =:userId')->setParameter('userId', $userId);
+            ->where('e.user =:userId')->setParameter('userId', $userId);
 
         if (null !== $isArchived) {
             $qb->andWhere('e.isArchived =:isArchived')->setParameter('isArchived', (bool) $isArchived);
@@ -114,10 +108,6 @@ class EntryRepository extends EntityRepository
             $qb->andWhere('e.isStarred =:isStarred')->setParameter('isStarred', (bool) $isStarred);
         }
 
-        if (null !== $isDeleted) {
-            $qb->andWhere('e.isDeleted =:isDeleted')->setParameter('isDeleted', (bool) $isDeleted);
-        }
-
         if ('created' === $sort) {
             $qb->orderBy('e.createdAt', $order);
         } elseif ('updated' === $sort) {
@@ -128,4 +118,15 @@ class EntryRepository extends EntityRepository
             ->getQuery()
             ->getResult();
     }
+
+    public function findOneWithTags()
+    {
+        $qb = $this->createQueryBuilder('e')
+            ->innerJoin('e.tags', 't')
+            ->addSelect('t');
+
+        return $qb
+            ->getQuery()
+            ->getOneOrNullResult();
+    }
 }