*/ class WebrootUserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, WebrootUser::class); } /** * Used to upgrade (rehash) the user's password automatically over time. */ public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void { if (!$user instanceof WebrootUser) { throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class)); } $user->setPassword($newHashedPassword); $this->getEntityManager()->persist($user); $this->getEntityManager()->flush(); } public function getAdministrators(): array { return $this->createQueryBuilder('w') ->andWhere('w.is_admin = :val') ->setParameter('val', true) ->orderBy('w.name','ASC') ->getQuery() ->getResult(); } public function hasAdministrator(): array { return (count( $this->createQueryBuilder('w') ->andWhere('w.is_admin = :val') ->setParameter('val', true) ->setMaxResults(1) ->getQuery() ->getResult() ) > 0); } // public function findOneBySomeField($value): ?WebrootUser // { // return $this->createQueryBuilder('w') // ->andWhere('w.exampleField = :val') // ->setParameter('val', $value) // ->getQuery() // ->getOneOrNullResult() // ; // } }