blob: ac3145a1dc8896d5ec8a980f3fee4769d37817ed (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
<?php
namespace Wallabag\CoreBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Pagerfanta;
class TagRepository extends EntityRepository
{
/**
* Find Tags.
*
* @param int $userId
*
* @return array
*/
public function findTags($userId)
{
$qb = $this->createQueryBuilder('t')
->where('t.user =:userId')->setParameter('userId', $userId);
$pagerAdapter = new DoctrineORMAdapter($qb);
return new Pagerfanta($pagerAdapter);
}
/**
* Find a tag by its label and its owner.
*
* @param string $label
* @param int $userId
*
* @return Tag|null
*/
public function findOneByLabelAndUserId($label, $userId)
{
return $this->createQueryBuilder('t')
->where('t.label = :label')->setParameter('label', $label)
->andWhere('t.user = :user_id')->setParameter('user_id', $userId)
->getQuery()
->getOneOrNullResult();
}
}
|