aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/FederationBundle/Repository/AccountRepository.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/FederationBundle/Repository/AccountRepository.php')
-rw-r--r--src/Wallabag/FederationBundle/Repository/AccountRepository.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/Wallabag/FederationBundle/Repository/AccountRepository.php b/src/Wallabag/FederationBundle/Repository/AccountRepository.php
new file mode 100644
index 00000000..e39bc582
--- /dev/null
+++ b/src/Wallabag/FederationBundle/Repository/AccountRepository.php
@@ -0,0 +1,48 @@
1<?php
2
3namespace Wallabag\FederationBundle\Repository;
4
5use Doctrine\ORM\EntityRepository;
6use Doctrine\ORM\QueryBuilder;
7
8class AccountRepository extends EntityRepository
9{
10 /**
11 * @param $accountId
12 * @return QueryBuilder
13 */
14 public function getBuilderForFollowingsByAccount($accountId)
15 {
16 return $this->createQueryBuilder('a')
17 ->select('f.id, f.username')
18 ->innerJoin('a.following', 'f')
19 ->where('a.id = :accountId')->setParameter('accountId', $accountId)
20 ;
21 }
22
23 /**
24 * @param $accountId
25 * @return QueryBuilder
26 */
27 public function getBuilderForFollowersByAccount($accountId)
28 {
29 return $this->createQueryBuilder('a')
30 ->innerJoin('a.followers', 'f')
31 ->where('a.id = :accountId')->setParameter('accountId', $accountId)
32 ;
33 }
34
35 /**
36 * @param $username
37 * @return QueryBuilder
38 * @throws \Doctrine\ORM\NonUniqueResultException
39 */
40 public function findAccountByUsername($username)
41 {
42 return $this->createQueryBuilder('a')
43 ->where('a.username = :username')->setParameter('username', $username)
44 ->andWhere('a.server = null')
45 ->getQuery()
46 ->getOneOrNullResult();
47 }
48}