->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.expired = false')
+ ->getQuery()
+ ->getSingleScalarResult();
+ }
}