X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FRepository%2FTagRepository.php;h=41f616079dd53f69032512adf6a1bfb176b98657;hb=9d7dd6b0d2480d3efff5b0ab1461f2ef99bfd57a;hp=ac3145a1dc8896d5ec8a980f3fee4769d37817ed;hpb=ec00964de22a338d8f814c5440f8e09f542fdbbf;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php index ac3145a1..41f61607 100644 --- a/src/Wallabag/CoreBundle/Repository/TagRepository.php +++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php @@ -3,8 +3,6 @@ namespace Wallabag\CoreBundle\Repository; use Doctrine\ORM\EntityRepository; -use Pagerfanta\Adapter\DoctrineORMAdapter; -use Pagerfanta\Pagerfanta; class TagRepository extends EntityRepository { @@ -15,30 +13,26 @@ class TagRepository extends EntityRepository * * @return array */ - public function findTags($userId) + public function findAllTags($userId) { - $qb = $this->createQueryBuilder('t') - ->where('t.user =:userId')->setParameter('userId', $userId); - - $pagerAdapter = new DoctrineORMAdapter($qb); - - return new Pagerfanta($pagerAdapter); + return $this->createQueryBuilder('t') + ->leftJoin('t.entries', 'e') + ->where('e.user = :userId')->setParameter('userId', $userId); } /** - * Find a tag by its label and its owner. - * - * @param string $label - * @param int $userId + * Used only in test case to get a tag for our entry. * - * @return Tag|null + * @return Tag */ - public function findOneByLabelAndUserId($label, $userId) + public function findOneByEntryAndTagLabel($entry, $label) { return $this->createQueryBuilder('t') - ->where('t.label = :label')->setParameter('label', $label) - ->andWhere('t.user = :user_id')->setParameter('user_id', $userId) + ->leftJoin('t.entries', 'e') + ->where('e.id = :entryId')->setParameter('entryId', $entry->getId()) + ->andWhere('t.label = :label')->setParameter('label', $label) + ->setMaxResults(1) ->getQuery() - ->getOneOrNullResult(); + ->getSingleResult(); } }