diff options
author | Thomas Citharel <tcit@tcit.fr> | 2017-05-31 09:31:18 +0200 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2017-06-23 10:08:54 +0200 |
commit | bf6c0346d8d35a719dd1bff1cb4d573d422f99ff (patch) | |
tree | 04fb80e20ad1cffacb72357a632a9afe2ec058cb /src/Wallabag/FederationBundle/Repository/AccountRepository.php | |
parent | d6d3f4ec3698effd1d4b063e295341791bdcf7d7 (diff) | |
download | wallabag-federation.tar.gz wallabag-federation.tar.zst wallabag-federation.zip |
WIPfederation
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.php | 48 |
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 | |||
3 | namespace Wallabag\FederationBundle\Repository; | ||
4 | |||
5 | use Doctrine\ORM\EntityRepository; | ||
6 | use Doctrine\ORM\QueryBuilder; | ||
7 | |||
8 | class 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 | } | ||