Skip to content

Commit 3e12e8b

Browse files
committed
Create user profile object if one doesn't exist
1 parent 679a2ee commit 3e12e8b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/controllers/User/Update.php

+21
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use \CarlBennett\MVC\Libraries\Router;
1616
use \CarlBennett\MVC\Libraries\View;
1717

18+
use \StdClass;
19+
1820
class Update extends Controller {
1921
public function &run(Router &$router, View &$view, array &$args) {
2022
$model = new UserUpdateModel();
@@ -64,6 +66,25 @@ public function &run(Router &$router, View &$view, array &$args) {
6466
$model->twitter_username = $model->profile->getTwitterUsername();
6567
$model->website = $model->profile->getWebsite(false);
6668

69+
} else {
70+
71+
$profile = new StdClass();
72+
73+
$profile->biography = $model->biography;
74+
$profile->discord_username = $model->discord_username;
75+
$profile->facebook_username = $model->facebook_username;
76+
$profile->github_username = $model->github_username;
77+
$profile->instagram_username = $model->instagram_username;
78+
$profile->phone = $model->phone;
79+
$profile->reddit_username = $model->reddit_username;
80+
$profile->skype_username = $model->skype_username;
81+
$profile->steam_id = $model->steam_id;
82+
$profile->twitter_username = $model->twitter_username;
83+
$profile->user_id = Authentication::$user->getId();
84+
$profile->website = $model->website;
85+
86+
$model->profile = new UserProfile($profile);
87+
6788
}
6889

6990
// process request

0 commit comments

Comments
 (0)