/** * Removes ownership of all workspaces currently owned by the given user * * @param User $user The user currently owning workspaces * @return void */ protected function removeOwnerFromUsersWorkspaces(User $user) { /** @var Workspace $workspace */ foreach ($this->workspaceRepository->findByOwner($user) as $workspace) { $workspace->setOwner(null); $this->workspaceRepository->update($workspace); } }
/** * Rebase a workspace * * This command sets a new base workspace for the specified workspace. Note that doing so will put the possible * changes contained in the workspace to be rebased into a different context and thus might lead to unintended * results when being published. * * @param string $workspace Name of the workspace to rebase, for example "user-john" * @param string $baseWorkspace Name of the new base workspace * @return void */ public function rebaseCommand($workspace, $baseWorkspace) { $workspaceName = $workspace; $workspace = $this->workspaceRepository->findOneByName($workspaceName); if (!$workspace instanceof Workspace) { $this->outputLine('Workspace "%s" does not exist', [$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); } $workspace->setBaseWorkspace($baseWorkspace); $this->workspaceRepository->update($workspace); $this->outputLine('Set "%s" as the new base workspace for "%s".', [$baseWorkspaceName, $workspaceName]); }
/** * Rebase the current users personal workspace onto the given $targetWorkspace and then * redirects to the $targetNode in the content module. * * @param NodeInterface $targetNode * @param Workspace $targetWorkspace * @return void */ public function rebaseAndRedirectAction(NodeInterface $targetNode, Workspace $targetWorkspace) { $currentAccount = $this->securityContext->getAccount(); $personalWorkspace = $this->workspaceRepository->findOneByName(UserUtility::getPersonalWorkspaceNameForUsername($currentAccount->getAccountIdentifier())); /** @var Workspace $personalWorkspace */ if ($personalWorkspace !== $targetWorkspace) { if ($this->publishingService->getUnpublishedNodesCount($personalWorkspace) > 0) { $message = $this->translator->translateById('workspaces.cantEditBecauseWorkspaceContainsChanges', [], null, null, 'Modules', 'Neos.Neos'); $this->addFlashMessage($message, '', Message::SEVERITY_WARNING, [], 1437833387); $this->redirect('show', null, null, ['workspace' => $targetWorkspace]); } $personalWorkspace->setBaseWorkspace($targetWorkspace); $this->workspaceRepository->update($personalWorkspace); } $contextProperties = $targetNode->getContext()->getProperties(); $contextProperties['workspaceName'] = $personalWorkspace->getName(); $context = $this->contextFactory->create($contextProperties); $mainRequest = $this->controllerContext->getRequest()->getMainRequest(); /** @var ActionRequest $mainRequest */ $this->uriBuilder->setRequest($mainRequest); $this->redirect('show', 'Frontend\\Node', 'Neos.Neos', ['node' => $context->getNode($targetNode->getPath())]); }
/** * Updates a workspace * * @param Workspace $workspace The updated workspace * @return void */ public function updateAction(Workspace $workspace) { $this->workspaceRepository->update($workspace); $this->throwStatus(200, 'Workspace updated', ''); }