getEntityManager()->persist($token); } public function findUserByTokenKey(string $tokenKey): ?User { $qb = $this->createQueryBuilder('at'); $qb ->select('at.user') ->where('at.key = :tokenKey') ->setParameter('tokenKey', $tokenKey) ; return $qb->getQuery()->getOneOrNullResult(); } }