Example #1
0
 /**
  * @param \Generated\Shared\Transfer\UserTransfer $userTransfer
  *
  * @return \Generated\Shared\Transfer\UserTransfer
  */
 public function save(UserTransfer $userTransfer)
 {
     if ($userTransfer->getIdUser() !== null) {
         $userEntity = $this->getEntityUserById($userTransfer->getIdUser());
     } else {
         $userEntity = new SpyUser();
     }
     $userEntity->setFirstName($userTransfer->getFirstName());
     $userEntity->setLastName($userTransfer->getLastName());
     $userEntity->setUsername($userTransfer->getUsername());
     if ($userTransfer->getStatus() !== null) {
         $userEntity->setStatus($userTransfer->getStatus());
     }
     if ($userTransfer->getLastLogin() !== null) {
         $userEntity->setLastLogin($userTransfer->getLastLogin());
     }
     $password = $userTransfer->getPassword();
     if (!empty($password) && $this->isRawPassword($userTransfer->getPassword())) {
         $userEntity->setPassword($this->encryptPassword($userTransfer->getPassword()));
     }
     $userEntity->save();
     $userTransfer = $this->entityToTransfer($userEntity);
     return $userTransfer;
 }
Example #2
0
 /**
  * @return \Orm\Zed\User\Persistence\SpyUser
  */
 protected function createTestUser()
 {
     $userEntity = new SpyUser();
     $userEntity->setUsername(self::TEST_MAIL);
     $userEntity->setFirstName('FirstName');
     $userEntity->setLastName('LastName');
     $userEntity->setPassword('Secret');
     $userEntity->setStatus(0);
     return $userEntity;
 }