예제 #1
0
 /**
  * {@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();
     }
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 protected function createToken($firewall, User $user)
 {
     return new UsernamePasswordToken($user, null, $firewall, $user->getRoles());
 }