]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/CoreBundle/Repository/TagRepository.php
Merge pull request #2306 from wallabag/redis-rabbit-check
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / TagRepository.php
CommitLineData
b3dc0749
NL
1<?php
2
3namespace Wallabag\CoreBundle\Repository;
4
5use Doctrine\ORM\EntityRepository;
b3dc0749 6
6d37a7e6 7class TagRepository extends EntityRepository
b3dc0749 8{
7244d6cb 9 /**
fc732227 10 * Find Tags.
7244d6cb 11 *
fc732227 12 * @param int $userId
7244d6cb 13 *
fc732227 14 * @return array
7244d6cb 15 */
fc732227 16 public function findAllTags($userId)
7244d6cb 17 {
e9023a16
NL
18 return $this->createQueryBuilder('t')
19 ->leftJoin('t.entries', 'e')
429d86f3 20 ->where('e.user = :userId')->setParameter('userId', $userId);
7244d6cb 21 }
567421af
TC
22
23 /**
24 * Used only in test case to get a tag for our entry.
25 *
26 * @return Tag
27 */
e686a76d 28 public function findOneByEntryAndTagLabel($entry, $label)
567421af
TC
29 {
30 return $this->createQueryBuilder('t')
31 ->leftJoin('t.entries', 'e')
32 ->where('e.id = :entryId')->setParameter('entryId', $entry->getId())
33 ->andWhere('t.label = :label')->setParameter('label', $label)
34 ->setMaxResults(1)
35 ->getQuery()
36 ->getSingleResult();
37 }
b3dc0749 38}