aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/GroupBundle/Repository/GroupRepository.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/GroupBundle/Repository/GroupRepository.php')
-rw-r--r--src/Wallabag/GroupBundle/Repository/GroupRepository.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Wallabag/GroupBundle/Repository/GroupRepository.php b/src/Wallabag/GroupBundle/Repository/GroupRepository.php
new file mode 100644
index 00000000..47340d07
--- /dev/null
+++ b/src/Wallabag/GroupBundle/Repository/GroupRepository.php
@@ -0,0 +1,33 @@
1<?php
2
3namespace Wallabag\GroupBundle\Repository;
4
5use Doctrine\ORM\EntityRepository;
6use Doctrine\ORM\QueryBuilder;
7use Wallabag\UserBundle\Entity\User;
8
9class 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}