/** * {@inheritdoc} */ public function validate($value, Constraint $constraint) { $res = $this->om->getRepository($this->class)->findOneBy(['usernameCanonical' => User::canonicalize($value)]); if (null !== $res) { $this->context->buildViolation($constraint->message)->addViolation(); } }
/** * Instanciate an Initiator from a User instance. * * @param User $user * * @return Initiator */ public static function fromUser(User $user) : Initiator { $initiator = new self($user->getId(), $user->getUsername(), $user->getEmail()); return $initiator; }
protected function createToken($firewall, User $user) { return new UsernamePasswordToken($user, null, $firewall, $user->getRoles()); }