]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | namespace Wallabag\CoreBundle\Repository; | |
4 | ||
5 | use Doctrine\ORM\EntityRepository; | |
6 | ||
7 | class TagRepository extends EntityRepository | |
8 | { | |
9 | /** | |
10 | * Find Tags. | |
11 | * | |
12 | * @param int $userId | |
13 | * | |
14 | * @return array | |
15 | */ | |
16 | public function findAllTags($userId) | |
17 | { | |
18 | return $this->createQueryBuilder('t') | |
19 | ->leftJoin('t.entries', 'e') | |
20 | ->where('e.user = :userId')->setParameter('userId', $userId) | |
21 | ->getQuery() | |
22 | ->getResult(); | |
23 | } | |
24 | ||
25 | /** | |
26 | * Used only in test case to get a tag for our entry. | |
27 | * | |
28 | * @return Tag | |
29 | */ | |
30 | public function findOneByEntryAndTagLabel($entry, $label) | |
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 | } | |
40 | } |