blob: be693d3b1312f6e86aae660c3798ee2b1e5d6530 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<?php
namespace Wallabag\UserBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Wallabag\UserBundle\Entity\User;
class UserRepository extends EntityRepository
{
/**
* Find a user by its username and rss roken.
*
* @param string $username
* @param string $rssToken
*
* @return User|null
*/
public function findOneByUsernameAndRsstoken($username, $rssToken)
{
return $this->createQueryBuilder('u')
->leftJoin('u.config', 'c')
->where('c.rssToken = :rss_token')->setParameter('rss_token', $rssToken)
->andWhere('u.username = :username')->setParameter('username', $username)
->getQuery()
->getOneOrNullResult();
}
/**
* Find a user by its username.
*
* @param string $username
*
* @return User
*/
public function findOneByUserName($username)
{
return $this->createQueryBuilder('u')
->andWhere('u.username = :username')->setParameter('username', $username)
->getQuery()
->getSingleResult();
}
/**
* Count how many users are enabled.
*
* @return int
*/
public function getSumEnabledUsers()
{
return $this->createQueryBuilder('u')
->select('count(u)')
->andWhere('u.enabled = true')
->getQuery()
->getSingleScalarResult();
}
/**
* Count how many users are existing.
*
* @return int
*/
public function getSumUsers()
{
return $this->createQueryBuilder('u')
->select('count(u)')
->getQuery()
->getSingleScalarResult();
}
/**
* Retrieves users filtered with a search term.
*
* @param string $term
*
* @return QueryBuilder
*/
public function getQueryBuilderForSearch($term)
{
return $this->createQueryBuilder('u')
->andWhere('lower(u.username) LIKE lower(:term) OR lower(u.email) LIKE lower(:term) OR lower(u.name) LIKE lower(:term)')->setParameter('term', '%' . $term . '%');
}
}
|