mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-11 17:51:02 +00:00
Move source files directly under src/ directory
This commit is contained in:
parent
804261bc26
commit
a37b385c23
190 changed files with 19 additions and 21 deletions
92
src/Repository/UserRepository.php
Normal file
92
src/Repository/UserRepository.php
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Repository;
|
||||
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Wallabag\CoreBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* @method User|null findOneById(int $id)
|
||||
*/
|
||||
class UserRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a user by its username and Feed token.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $feedToken
|
||||
*
|
||||
* @return User|null
|
||||
*/
|
||||
public function findOneByUsernameAndFeedtoken($username, $feedToken)
|
||||
{
|
||||
return $this->createQueryBuilder('u')
|
||||
->leftJoin('u.config', 'c')
|
||||
->where('c.feedToken = :feed_token')->setParameter('feed_token', $feedToken)
|
||||
->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 . '%');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue