aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/FederationBundle/Repository/AccountRepository.php
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2017-05-31 09:31:18 +0200
committerThomas Citharel <tcit@tcit.fr>2017-06-23 10:08:54 +0200
commitbf6c0346d8d35a719dd1bff1cb4d573d422f99ff (patch)
tree04fb80e20ad1cffacb72357a632a9afe2ec058cb /src/Wallabag/FederationBundle/Repository/AccountRepository.php
parentd6d3f4ec3698effd1d4b063e295341791bdcf7d7 (diff)
downloadwallabag-federation.tar.gz
wallabag-federation.tar.zst
wallabag-federation.zip
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
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}