Ejemplo n.º 1
0
 /**
  * @param User $userModel
  *
  * @return UserEntity
  */
 public static function build(User $userModel)
 {
     $user = new UserEntity(new UserId($userModel->getId()), $userModel->getName(), $userModel->getEmail(), $userModel->getUsername(), [$userModel->getRoles()], $userModel->getSalt(), $userModel->getPassword());
     $user->setSurname($userModel->getSurname());
     $user->setEnabled($userModel->isEnabled());
     $user->setCreatedAt($userModel->getCreatedAt());
     $user->setAccountNonExpired($userModel->isAccountNonExpired());
     $user->setAccountNonLocked($userModel->isAccountNonLocked());
     $user->setCredentialsNonExpired($userModel->isCredentialsNonExpired());
     return $user;
 }
Ejemplo n.º 2
0
 /**
  * @param UserEntity $user
  *
  * @return User
  */
 public static function build(UserEntity $user)
 {
     $userModel = new User();
     $userModel->setId($user->getId()->id());
     $userModel->setName($user->getName());
     $userModel->setSurname($user->getSurname());
     $userModel->setEmail($user->getEmail());
     $userModel->setUsername($user->getUsername());
     $userModel->setSalt($user->getSalt());
     $userModel->setPassword($user->getPassword());
     $userModel->setCreatedAt($user->getCreatedAt());
     $userModel->setEnabled($user->isEnabled());
     $userModel->setAccountNonExpired($user->isAccountNonExpired());
     $userModel->setAccountNonLocked($user->isAccountNonLocked());
     $userModel->setCredentialsNonExpired($user->isCredentialsNonExpired());
     $userModel->setRoles($user->getRoles()[0]);
     return $userModel;
 }