|
|
|
@ -17,15 +17,12 @@ use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
|
|
|
|
* @method User[] findAll()
|
|
|
|
|
* @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
|
|
|
*/
|
|
|
|
|
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
|
|
|
|
|
{
|
|
|
|
|
public function __construct(ManagerRegistry $registry)
|
|
|
|
|
{
|
|
|
|
|
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface {
|
|
|
|
|
public function __construct (ManagerRegistry $registry) {
|
|
|
|
|
parent::__construct($registry, User::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function save(User $entity, bool $flush = false): void
|
|
|
|
|
{
|
|
|
|
|
public function save (User $entity, bool $flush = false): void {
|
|
|
|
|
$this->getEntityManager()->persist($entity);
|
|
|
|
|
|
|
|
|
|
if ($flush) {
|
|
|
|
@ -33,8 +30,7 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function remove(User $entity, bool $flush = false): void
|
|
|
|
|
{
|
|
|
|
|
public function remove (User $entity, bool $flush = false): void {
|
|
|
|
|
$this->getEntityManager()->remove($entity);
|
|
|
|
|
|
|
|
|
|
if ($flush) {
|
|
|
|
@ -45,8 +41,7 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
|
|
|
|
|
/**
|
|
|
|
|
* Used to upgrade (rehash) the user's password automatically over time.
|
|
|
|
|
*/
|
|
|
|
|
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
|
|
|
|
|
{
|
|
|
|
|
public function upgradePassword (PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void {
|
|
|
|
|
if (!$user instanceof User) {
|
|
|
|
|
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
|
|
|
|
|
}
|
|
|
|
@ -56,28 +51,28 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
|
|
|
|
|
$this->save($user, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
// * @return User[] Returns an array of User objects
|
|
|
|
|
// */
|
|
|
|
|
// public function findByExampleField($value): array
|
|
|
|
|
// {
|
|
|
|
|
// return $this->createQueryBuilder('u')
|
|
|
|
|
// ->andWhere('u.exampleField = :val')
|
|
|
|
|
// ->setParameter('val', $value)
|
|
|
|
|
// ->orderBy('u.id', 'ASC')
|
|
|
|
|
// ->setMaxResults(10)
|
|
|
|
|
// ->getQuery()
|
|
|
|
|
// ->getResult()
|
|
|
|
|
// ;
|
|
|
|
|
// }
|
|
|
|
|
// /**
|
|
|
|
|
// * @return User[] Returns an array of User objects
|
|
|
|
|
// */
|
|
|
|
|
// public function findByExampleField($value): array
|
|
|
|
|
// {
|
|
|
|
|
// return $this->createQueryBuilder('u')
|
|
|
|
|
// ->andWhere('u.exampleField = :val')
|
|
|
|
|
// ->setParameter('val', $value)
|
|
|
|
|
// ->orderBy('u.id', 'ASC')
|
|
|
|
|
// ->setMaxResults(10)
|
|
|
|
|
// ->getQuery()
|
|
|
|
|
// ->getResult()
|
|
|
|
|
// ;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// public function findOneBySomeField($value): ?User
|
|
|
|
|
// {
|
|
|
|
|
// return $this->createQueryBuilder('u')
|
|
|
|
|
// ->andWhere('u.exampleField = :val')
|
|
|
|
|
// ->setParameter('val', $value)
|
|
|
|
|
// ->getQuery()
|
|
|
|
|
// ->getOneOrNullResult()
|
|
|
|
|
// ;
|
|
|
|
|
// }
|
|
|
|
|
// public function findOneBySomeField($value): ?User
|
|
|
|
|
// {
|
|
|
|
|
// return $this->createQueryBuilder('u')
|
|
|
|
|
// ->andWhere('u.exampleField = :val')
|
|
|
|
|
// ->setParameter('val', $value)
|
|
|
|
|
// ->getQuery()
|
|
|
|
|
// ->getOneOrNullResult()
|
|
|
|
|
// ;
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|