Exemple #1
0
 /**
  * @param string $value (optional) For instantiation of an existing Identity
  */
 public function __construct(string $value = null)
 {
     if (null === $value) {
         $this->id = $this->generateId();
         return;
     }
     Assertion::string($value);
     $this->id = $value;
 }
Exemple #2
0
 /**
  * Change the email address of the user.
  *
  * @param string $email
  */
 public function changeEmail(string $email)
 {
     Assertion::email($email);
     $oldEmail = $this->email;
     $this->email = $email;
     $this->emailCanonical = self::canonicalize($this->email);
     $this->updated = new DateTime();
     $this->record(new EmailChanged($this->getId(), $oldEmail, $this->email));
 }
Exemple #3
0
 /**
  * @param string                       $username
  * @param string                       $email
  * @param string                       $plainPassword
  * @param UserPasswordEncoderInterface $encoder
  * @param array                        $roles
  */
 protected function __construct(string $username, string $email, string $plainPassword, UserPasswordEncoderInterface $encoder, array $roles = [])
 {
     Assertion::email($email);
     $this->id = new Identity();
     $this->roles = $roles;
     $this->salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
     $this->created = new DateTime();
     $this->username = $username;
     $this->email = $email;
     $this->updateCanonicalFields();
     $this->updatePassword($plainPassword, $encoder);
 }