コード例 #1
0
ファイル: UserService.php プロジェクト: fuca/sportsclub
 /**
  * Calls rollback
  * @param \App\Model\Entities\User $uDb
  * @param \App\Model\Entities\User $formUser
  * @throws Exceptions\DuplicateEntryException
  * @throws Exceptions\DataErrorException
  */
 private function handleUpdateUser(User $uDb, User $formUser)
 {
     $identifier = null;
     $now = new DateTime();
     try {
         $this->editorTypeHandle($uDb->getWebProfile());
         $formUser->setWebProfile($uDb->getWebProfile());
         $formUser->setCreated($uDb->getCreated());
         $formUser->setUpdated($now);
         $formUser->setLastLogin($uDb->getLastLogin());
         $formUser->setContact($uDb->getContact());
         $uDb->fromArray($formUser->toArray());
         $this->entityManager->merge($uDb);
         $this->entityManager->flush();
     } catch (DuplicateEntryException $e) {
         $this->imageService->removeResource($identifier);
         throw new Exceptions\DuplicateEntryException($e->getMessage(), $e->getCode(), $e->getPrevious());
     } catch (\Exception $e) {
         $this->imageService->removeResource($identifier);
         throw new Exceptions\DataErrorException($e->getMessage(), $e->getCode(), $e->getPrevious());
     }
 }