X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FRepository%2FEntryRepository.php;h=a8085ac9cbeb01bdc4c7bb6331ef1b72f6380765;hb=092ca70725b0263390e45c46f93828c613eca3f0;hp=1805cf3f4b1b3bfdf284a2517234e7f84c02ebff;hpb=2c0ffcf3972e2f58267b805a26835f452e016761;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 1805cf3f..a8085ac9 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -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(); @@ -94,17 +90,15 @@ class EntryRepository extends EntityRepository * @param int $userId * @param bool $isArchived * @param bool $isStarred - * @param bool $isDeleted * @param string $sort * @param string $order * - * @return ArrayCollection + * @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) { @@ -126,6 +116,25 @@ class EntryRepository extends EntityRepository return $qb ->getQuery() - ->getResult(Query::HYDRATE_ARRAY); + ->getResult(); + } + + /** + * Fetch an entry with a tag. Only used for tests. + * + * @return Entry + */ + public function findOneWithTags($userId) + { + $qb = $this->createQueryBuilder('e') + ->innerJoin('e.tags', 't') + ->addSelect('t') + ->where('t.user=:userId')->setParameter('userId', 1); + + return $qb->getQuery()->getOneOrNullResult(); + + return $qb + ->getQuery() + ->getOneOrNullResult(); } }