コード例 #1
0
ファイル: Identity.php プロジェクト: hmlb/ddd
 /**
  * @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;
 }
コード例 #2
0
ファイル: User.php プロジェクト: hmlb/user-bundle
 /**
  * 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));
 }
コード例 #3
0
ファイル: User.php プロジェクト: hmlb/userbundle
 /**
  * @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);
 }