/**
* Creates a personal workspace for the given user's account if it does not exist already.
*
* @param User $user The new user to create a workspace for
* @param Account $account The user's backend account
* @throws IllegalObjectTypeException
*/
protected function createPersonalWorkspace(User $user, Account $account)
{
$userWorkspaceName = UserUtility::getPersonalWorkspaceNameForUsername($account->getAccountIdentifier());
$userWorkspace = $this->workspaceRepository->findByIdentifier($userWorkspaceName);
if ($userWorkspace === null) {
$liveWorkspace = $this->workspaceRepository->findByIdentifier('live');
if (!$liveWorkspace instanceof Workspace) {
$liveWorkspace = new Workspace('live');
$liveWorkspace->setTitle('Live');
$this->workspaceRepository->add($liveWorkspace);
}
$userWorkspace = new Workspace($userWorkspaceName, $liveWorkspace, $user);
$userWorkspace->setTitle((string) $user->getName());
$this->workspaceRepository->add($userWorkspace);
}
}