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