コード例 #1
0
 /**
  * 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');
 }