]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | namespace Wallabag\GroupBundle\Repository; | |
4 | ||
5 | use Doctrine\ORM\EntityRepository; | |
6 | use Doctrine\ORM\QueryBuilder; | |
7 | use Wallabag\UserBundle\Entity\User; | |
8 | ||
9 | class GroupRepository extends EntityRepository | |
10 | { | |
11 | /** | |
12 | * Return a query builder to used by other getBuilderFor* method. | |
13 | * | |
14 | * @return QueryBuilder | |
15 | */ | |
16 | public function getBuilder() | |
17 | { | |
18 | return $this->createQueryBuilder('g'); | |
19 | } | |
20 | ||
21 | public function findPublicGroups() | |
22 | { | |
23 | return $this->getBuilder() | |
24 | ->where('g.acceptSystem < 10'); | |
25 | } | |
26 | ||
27 | public function findGroupsByUser(User $user) | |
28 | { | |
29 | return $this->getBuilder() | |
30 | ->join('Wallabag\GroupBundle\Entity\UserGroup', 'u', 'WITH', 'u.group = g.id') | |
31 | ->where('u.user = :user')->setParameter(':user', $user->getId()); | |
32 | } | |
33 | } |