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->email = $inputReader->email;
$this->password = $inputReader->password;
$this->accessRank = $inputReader->accessRank;
$this->avatarStyle = $inputReader->avatarStyle;
if ($inputReader->accessRank !== null)
$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->browsingSettings = $inputReader->browsingSettings;
}

View file

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