]>
Commit | Line | Data |
---|---|---|
b3dc0749 NL |
1 | <?php |
2 | ||
3 | namespace Wallabag\CoreBundle\Repository; | |
4 | ||
5 | use Doctrine\ORM\EntityRepository; | |
b3dc0749 | 6 | |
6d37a7e6 | 7 | class 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') | |
20 | ->where('e.user = :userId')->setParameter('userId', $userId) | |
7244d6cb | 21 | ->getQuery() |
fc732227 | 22 | ->getResult(); |
7244d6cb | 23 | } |
567421af TC |
24 | |
25 | /** | |
26 | * Used only in test case to get a tag for our entry. | |
27 | * | |
28 | * @return Tag | |
29 | */ | |
e686a76d | 30 | public function findOneByEntryAndTagLabel($entry, $label) |
567421af TC |
31 | { |
32 | return $this->createQueryBuilder('t') | |
33 | ->leftJoin('t.entries', 'e') | |
34 | ->where('e.id = :entryId')->setParameter('entryId', $entry->getId()) | |
35 | ->andWhere('t.label = :label')->setParameter('label', $label) | |
36 | ->setMaxResults(1) | |
37 | ->getQuery() | |
38 | ->getSingleResult(); | |
39 | } | |
b3dc0749 | 40 | } |