*/ class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, User::class); } /** Used to upgrade (rehash) the user's password automatically over time. * @param User $user * */ public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void { $user->password = $newHashedPassword; $this->getEntityManager()->persist($user); $this->getEntityManager()->flush(); } public function makeAdmin(string $email): void { $user = $this->findOneBy(['email' => $email]); if (!$user instanceof User) { throw new \InvalidArgumentException('User not found'); } $user->roles = ['ROLE_ADMIN']; $this->getEntityManager()->flush(); } }