From 847117a408398724883e96ac7455fc90d7faec38 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 13 Sep 2014 20:12:42 +0200 Subject: [PATCH] Shifted data transform responsibility from service --- src/FormData/UserEditFormData.php | 6 ++++-- src/Services/UserService.php | 8 ++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/FormData/UserEditFormData.php b/src/FormData/UserEditFormData.php index ef78d6b5..db23b832 100644 --- a/src/FormData/UserEditFormData.php +++ b/src/FormData/UserEditFormData.php @@ -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; } diff --git a/src/Services/UserService.php b/src/Services/UserService.php index 1cf80d97..e57a0e2a 100644 --- a/src/Services/UserService.php +++ b/src/Services/UserService.php @@ -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);