X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FUserBundle%2FRepository%2FUserRepository.php;h=f913f52dd5beaf0fed96d38c940d230a98be07ba;hb=1093e979ff49f9072c30d1d576c6adf1f8e76bdf;hp=c020f3ca9478a6418ec1e4bc6732610a5999fe7b;hpb=1210dae10589515d6f3824c75639342c5e1d52dd;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/UserBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php index c020f3ca..f913f52d 100644 --- a/src/Wallabag/UserBundle/Repository/UserRepository.php +++ b/src/Wallabag/UserBundle/Repository/UserRepository.php @@ -23,4 +23,33 @@ class UserRepository extends EntityRepository ->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(); + } }