load doctrine extensions during kernel bootstrap #84 (#92)

This commit is contained in:
Kevin Papst
2018-01-16 21:35:23 +01:00
committed by GitHub
parent 3f221fcdb8
commit 0a65965187
11 changed files with 126 additions and 172 deletions

View File

@@ -14,13 +14,14 @@ namespace App\Repository;
use App\Entity\User;
use App\Model\UserStatistic;
use App\Repository\Query\UserQuery;
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
/**
* Class UserRepository
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class UserRepository extends AbstractRepository
class UserRepository extends AbstractRepository implements UserLoaderInterface
{
/**
@@ -65,4 +66,20 @@ class UserRepository extends AbstractRepository
return $this->getPager($qb->getQuery(), $query->getPage(), $query->getPageSize());
}
/**
* @param string $username
* @return mixed|null|\Symfony\Component\Security\Core\User\UserInterface
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function loadUserByUsername($username)
{
return $this->createQueryBuilder('u')
->where('u.username = :username')
->orWhere('u.email = :username')
->setParameter('username', $username)
->getQuery()
->getSingleResult();
}
}