public function createUserProfileIfMissing($user)
 {
     if (!isset($user)) {
         throw new \Exception('User (so therefore Profile) does not exist.');
     }
     $userProfile = $user->getUserProfile();
     if ($userProfile == null) {
         $userProfile = new UserProfile();
         $userProfile->setUser($user);
         $user->setUserProfile($userProfile);
         $this->em->persist($userProfile);
         $this->em->persist($user);
         $this->em->flush();
     }
     $userProfile = $this->attachMissingUserProfileValues($userProfile);
     return $userProfile;
 }