File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -128,23 +128,24 @@ interface only requires one method: ``loadUserByUsername($username)``::
128
128
// src/Repository/UserRepository.php
129
129
namespace App\Repository;
130
130
131
- use Doctrine\ORM\EntityRepository ;
131
+ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository ;
132
132
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
133
133
134
- class UserRepository extends EntityRepository implements UserLoaderInterface
134
+ class UserRepository extends ServiceEntityRepository implements UserLoaderInterface
135
135
{
136
136
// ...
137
137
138
138
public function loadUserByUsername($usernameOrEmail)
139
139
{
140
- return $this->createQuery(
140
+ $entityManager = $this->getEntityManager();
141
+
142
+ return $entityManager->createQuery(
141
143
'SELECT u
142
144
FROM App\Entity\User u
143
145
WHERE u.username = :query
144
146
OR u.email = :query'
145
147
)
146
148
->setParameter('query', $usernameOrEmail)
147
- ->getQuery()
148
149
->getOneOrNullResult();
149
150
}
150
151
}
You can’t perform that action at this time.
0 commit comments