public function updateProfileCommon(User $user, User $new)
 {
     $user->setFirstName($new->getFirstName())->setLastName($new->getLastName())->setBirth($new->getBirth())->setAddress1($new->getAddress1())->setAddress2($new->getAddress2())->setCity($new->getCity())->setState($new->getState())->setCountry($new->getCountry())->setZip($new->getZip())->setEmail($new->getEmail())->setPhone($new->getPhone())->setFacebookLink($new->getFacebookLink())->setTwitterLink($new->getTwitterLink())->setUpdateProfileAt(new \DateTime())->setBio($new->getBio())->setSlogan($new->getSlogan())->setInterests($new->getInterests());
     if ($new->getPassword()) {
         $user->setPassword($new->getPassword())->setSalt($new->getSalt());
     }
     if ($new->getAvatarFileName() && $new->getAvatarFileName() !== $user->getAvatarFileName()) {
         $img = imagecreatefromstring(base64_decode($new->getAvatarFileName()));
         if ($img != false) {
             $filename = $user->getId() . '_' . uniqid() . '.jpeg';
             $temp_file = tempnam(sys_get_temp_dir(), 'avatar');
             if (imagejpeg($img, $temp_file)) {
                 //square avatars
                 try {
                     $this->cropImageService->rebuildImage($temp_file, $temp_file);
                 } catch (\Exception $exc) {
                 }
                 $fileUpload = new UploadedFile($temp_file, $filename);
                 $user->setAvatar($fileUpload);
             }
         }
     }
     $user->setIsRegistrationComplete(true);
 }
Example #2
0
 public static function toUserOwnerData(User $user)
 {
     return ['id' => $user->getId(), 'type' => $user->getType(), 'official_title' => '', 'first_name' => $user->getFirstName(), 'last_name' => $user->getLastName(), 'avatar_file_path' => $user->getAvatarFileName()];
 }
 public function getFirstName()
 {
     $this->__load();
     return parent::getFirstName();
 }