Shifted data transform responsibility from service

This commit is contained in:
Marcin Kurczewski 2014-09-13 20:12:42 +02:00
parent dfb1198143
commit 847117a408
2 changed files with 6 additions and 8 deletions

View file

@ -18,8 +18,10 @@ class UserEditFormData implements \Szurubooru\IValidatable
$this->userName = $inputReader->userName; $this->userName = $inputReader->userName;
$this->email = $inputReader->email; $this->email = $inputReader->email;
$this->password = $inputReader->password; $this->password = $inputReader->password;
$this->accessRank = $inputReader->accessRank; if ($inputReader->accessRank !== null)
$this->avatarStyle = $inputReader->avatarStyle; $this->accessRank = \Szurubooru\Helpers\EnumHelper::accessRankFromString($inputReader->accessRank);
if ($inputReader->avatarStyle !== null)
$this->avatarStyle = \Szurubooru\Helpers\EnumHelper::avatarStyleFromString($inputReader->avatarStyle);
$this->avatarContent = $inputReader->avatarContent; $this->avatarContent = $inputReader->avatarContent;
$this->browsingSettings = $inputReader->browsingSettings; $this->browsingSettings = $inputReader->browsingSettings;
} }

View file

@ -97,11 +97,7 @@ class UserService
$this->validator->validate($formData); $this->validator->validate($formData);
if ($formData->avatarStyle !== null) if ($formData->avatarStyle !== null)
{ $this->updateUserAvatarStyle($user, $formData->avatarStyle);
$this->updateUserAvatarStyle(
$user,
\Szurubooru\Helpers\EnumHelper::avatarStyleFromString($formData->avatarStyle));
}
if ($formData->avatarContent !== null) if ($formData->avatarContent !== null)
$this->updateUserAvatarContent($user, $formData->avatarContent); $this->updateUserAvatarContent($user, $formData->avatarContent);
@ -116,7 +112,7 @@ class UserService
$this->updateUserEmail($user, $formData->email); $this->updateUserEmail($user, $formData->email);
if ($formData->accessRank !== null) if ($formData->accessRank !== null)
$this->updateUserAccessRank($user, \Szurubooru\Helpers\EnumHelper::accessRankFromString($formData->accessRank)); $this->updateUserAccessRank($user, $formData->accessRank);
if ($formData->browsingSettings !== null) if ($formData->browsingSettings !== null)
$this->updateUserBrowsingSettings($user, $formData->browsingSettings); $this->updateUserBrowsingSettings($user, $formData->browsingSettings);