public function createCommand($workspace, $baseWorkspace = 'live', $title = null, $description = null, $owner = '')
{
$workspaceName = $workspace;
$workspace = $this->workspaceRepository->findOneByName($workspaceName);
if ($workspace instanceof Workspace) {
$this->outputLine('Workspace "%s" already exists', [$workspaceName]);
$this->quit(1);
}
$baseWorkspaceName = $baseWorkspace;
$baseWorkspace = $this->workspaceRepository->findOneByName($baseWorkspaceName);
if (!$baseWorkspace instanceof Workspace) {
$this->outputLine('The base workspace "%s" does not exist', [$baseWorkspaceName]);
$this->quit(2);
}
if ($owner === '') {
$owningUser = null;
} else {
$owningUser = $this->userService->getUser($owner);
if ($owningUser === null) {
$this->outputLine('The user "%s" specified as owner does not exist', [$owner]);
$this->quit(3);
}
}
if ($title === null) {
$title = $workspaceName;
}
$workspace = new Workspace($workspaceName, $baseWorkspace, $owningUser);
$workspace->setTitle($title);
$workspace->setDescription($description);
$this->workspaceRepository->add($workspace);
if ($owningUser instanceof User) {
$this->outputLine('Created a new workspace "%s", based on workspace "%s", owned by "%s".', [$workspaceName, $baseWorkspaceName, $owner]);
} else {
$this->outputLine('Created a new workspace "%s", based on workspace "%s".', [$workspaceName, $baseWorkspaceName]);
}
}