/** * Create a new workspace * * This command creates a new workspace. * * @param string $workspace Name of the workspace, for example "christmas-campaign" * @param string $baseWorkspace Name of the base workspace. If none is specified, "live" is assumed. * @param string $title Human friendly title of the workspace, for example "Christmas Campaign" * @param string $description A description explaining the purpose of the new workspace * @return void */ public function createCommand($workspace, $baseWorkspace = 'live', $title = NULL, $description = NULL) { $workspaceName = $workspace; $workspace = $this->workspaceRepository->findOneByName($workspaceName); if ($workspace instanceof Workspace) { $this->outputLine('Workspace "%s" already exists', array($workspaceName)); $this->quit(1); } $baseWorkspaceName = $baseWorkspace; $baseWorkspace = $this->workspaceRepository->findOneByName($baseWorkspaceName); if (!$baseWorkspace instanceof Workspace) { $this->outputLine('The base workspace "%s" does not exist', array($baseWorkspaceName)); $this->quit(2); } if ($title === NULL) { $title = $workspaceName; } $workspace = new Workspace($workspaceName, $baseWorkspace); $workspace->setTitle($title); $workspace->setDescription($description); $this->workspaceRepository->add($workspace); $this->outputLine('Created a new workspace "%s", based on workspace "%s".', array($workspaceName, $baseWorkspaceName)); }
/** * Create a workspace * * @Flow\Validate(argumentName="title", type="\TYPO3\Flow\Validation\Validator\NotEmptyValidator") * @param string $title Human friendly title of the workspace, for example "Christmas Campaign" * @param Workspace $baseWorkspace Workspace the new workspace should be based on * @param string $visibility Visibility of the new workspace, must be either "internal" or "shared" * @param string $description A description explaining the purpose of the new workspace * @return void */ public function createAction($title, Workspace $baseWorkspace, $visibility, $description = '') { $workspace = $this->workspaceRepository->findOneByTitle($title); if ($workspace instanceof Workspace) { $this->addFlashMessage($this->translator->translateById('workspaces.workspaceWithThisTitleAlreadyExists', [], null, null, 'Modules', 'TYPO3.Neos'), '', Message::SEVERITY_WARNING); $this->redirect('new'); } $workspaceName = Utility::renderValidNodeName($title) . '-' . substr(base_convert(microtime(false), 10, 36), -5, 5); while ($this->workspaceRepository->findOneByName($workspaceName) instanceof Workspace) { $workspaceName = Utility::renderValidNodeName($title) . '-' . substr(base_convert(microtime(false), 10, 36), -5, 5); } if ($visibility === 'private') { $owner = $this->userService->getCurrentUser(); } else { $owner = null; } $workspace = new Workspace($workspaceName, $baseWorkspace, $owner); $workspace->setTitle($title); $workspace->setDescription($description); $this->workspaceRepository->add($workspace); $this->redirect('index'); }
/** * Create a new workspace * * This command creates a new workspace. * * @param string $workspace Name of the workspace, for example "christmas-campaign" * @param string $baseWorkspace Name of the base workspace. If none is specified, "live" is assumed. * @param string $title Human friendly title of the workspace, for example "Christmas Campaign" * @param string $description A description explaining the purpose of the new workspace * @param string $owner The identifier of a User to own the workspace * @return void */ 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]); } }