]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/GroupBundle/Repository/GroupRepository.php
WIP
[github/wallabag/wallabag.git] / src / Wallabag / GroupBundle / Repository / GroupRepository.php
diff --git a/src/Wallabag/GroupBundle/Repository/GroupRepository.php b/src/Wallabag/GroupBundle/Repository/GroupRepository.php
new file mode 100644 (file)
index 0000000..47340d0
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+namespace Wallabag\GroupBundle\Repository;
+
+use Doctrine\ORM\EntityRepository;
+use Doctrine\ORM\QueryBuilder;
+use Wallabag\UserBundle\Entity\User;
+
+class GroupRepository extends EntityRepository
+{
+    /**
+     * Return a query builder to used by other getBuilderFor* method.
+     *
+     * @return QueryBuilder
+     */
+    public function getBuilder()
+    {
+        return $this->createQueryBuilder('g');
+    }
+
+    public function findPublicGroups()
+    {
+        return $this->getBuilder()
+            ->where('g.acceptSystem < 10');
+    }
+
+    public function findGroupsByUser(User $user)
+    {
+        return $this->getBuilder()
+            ->join('Wallabag\GroupBundle\Entity\UserGroup', 'u', 'WITH', 'u.group = g.id')
+            ->where('u.user = :user')->setParameter(':user', $user->getId());
+    }
+}