|
1
|
|
|
<?php |
|
2
|
|
|
namespace Vivait\AuthBundle\Entity; |
|
3
|
|
|
|
|
4
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
|
5
|
|
|
use Symfony\Component\Security\Core\User\UserProviderInterface; |
|
6
|
|
|
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; |
|
7
|
|
|
use Symfony\Component\Security\Core\Exception\UnsupportedUserException; |
|
8
|
|
|
use Doctrine\ORM\EntityRepository; |
|
9
|
|
|
use Doctrine\ORM\NoResultException; |
|
10
|
|
|
|
|
11
|
|
|
class UserRepository extends EntityRepository implements UserProviderInterface { |
|
12
|
|
|
public function loadUserByUsername($username) { |
|
13
|
|
|
$q = $this |
|
14
|
|
|
->createQueryBuilder('u') |
|
15
|
|
|
->select('u, g, t') |
|
16
|
|
|
->leftJoin('u.groups', 'g') |
|
17
|
|
|
->leftJoin('u.tenants', 't') |
|
18
|
|
|
->where('(LOWER(u.username) = :username OR LOWER(u.email) = :email)') |
|
19
|
|
|
->setParameter('username', $username) |
|
20
|
|
|
->setParameter('email', $username) |
|
21
|
|
|
->getQuery(); |
|
22
|
|
|
try { |
|
23
|
|
|
// The Query::getSingleResult() method throws an exception |
|
24
|
|
|
// if there is no record matching the criteria. |
|
25
|
|
|
$user = $q->getSingleResult(); |
|
26
|
|
|
} catch (NoResultException $e) { |
|
|
|
|
|
|
27
|
|
|
$message = sprintf( |
|
28
|
|
|
'Unable to find an active user object identified by "%s".', |
|
29
|
|
|
$username |
|
30
|
|
|
); |
|
31
|
|
|
throw new UsernameNotFoundException($message, 0, $e); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
return $user; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function findAllFull() { |
|
|
|
|
|
|
38
|
|
|
return $this |
|
39
|
|
|
->createQueryBuilder('u') |
|
40
|
|
|
->select('u, g, t') |
|
41
|
|
|
->leftJoin('u.groups', 'g') |
|
42
|
|
|
->leftJoin('u.tenants', 't') |
|
43
|
|
|
->getQuery(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function refreshUser(UserInterface $user) { |
|
47
|
|
|
$class = get_class($user); |
|
48
|
|
|
if (!$this->supportsClass($class)) { |
|
49
|
|
|
throw new UnsupportedUserException( |
|
50
|
|
|
sprintf( |
|
51
|
|
|
'Instances of "%s" are not supported.', |
|
52
|
|
|
$class |
|
53
|
|
|
) |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
return $this->find($user->getId()); |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function supportsClass($class) { |
|
61
|
|
|
return $this->getEntityName() === $class |
|
62
|
|
|
|| is_subclass_of($class, $this->getEntityName()); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
?> |
|
|
|
|
|
|
67
|
|
|
|
Scrutinizer analyzes your
composer.json/composer.lockfile if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.