1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Repository; |
4
|
|
|
|
5
|
|
|
use ControleOnline\Entity\User; |
6
|
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
|
|
|
|
7
|
|
|
use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface; |
|
|
|
|
8
|
|
|
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; |
|
|
|
|
9
|
|
|
use Doctrine\Persistence\ManagerRegistry; |
|
|
|
|
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @method User|null find($id, $lockMode = null, $lockVersion = null) |
13
|
|
|
* @method User|null findOneBy(array $criteria, array $orderBy = null) |
14
|
|
|
* @method User[] findAll() |
15
|
|
|
* @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
16
|
|
|
*/ |
17
|
|
|
class UserRepository extends ServiceEntityRepository implements UserLoaderInterface |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
public function __construct(ManagerRegistry $registry) |
21
|
|
|
{ |
22
|
|
|
parent::__construct($registry, User::class); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function loadUserByIdentifier(string $identifier): ?\Symfony\Component\Security\Core\User\UserInterface |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
return $this->createQueryBuilder('u') |
28
|
|
|
->andWhere('u.username = :identifier') |
29
|
|
|
->setParameter('identifier', $identifier) |
30
|
|
|
->getQuery() |
31
|
|
|
->getOneOrNullResult(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
public function updatePassword(string $email, string $password): ?User |
36
|
|
|
{ |
37
|
|
|
if ($user = $this->findOneByEmail($email)) { |
38
|
|
|
$user->setPassword($password); |
39
|
|
|
|
40
|
|
|
$this->getEntityManager()->persist($user); |
41
|
|
|
|
42
|
|
|
$this->getEntityManager()->flush(); |
43
|
|
|
|
44
|
|
|
return $user; |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getActiveUserByEmail($email) |
49
|
|
|
{ |
50
|
|
|
return $this->createQueryBuilder('u') |
51
|
|
|
->where('u.email = :email') |
52
|
|
|
->andwhere('u.active = 1') |
53
|
|
|
->setParameter('email', $email) |
54
|
|
|
->getQuery()->getOneOrNullResult(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function loadUserByUsername($username) |
58
|
|
|
{ |
59
|
|
|
return $this->createQueryBuilder('u') |
60
|
|
|
->where('u.username = :username') |
61
|
|
|
->setParameter('username', $username) |
62
|
|
|
->getQuery()->getOneOrNullResult(); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths