/** * Remove dimensions on nodes "/" and "/sites" * * This empties the content dimensions on those nodes, so when traversing via the Node API from the root node, * the nodes below "/sites" are always reachable. * * @param string $workspaceName * @param boolean $dryRun * @return void */ public function removeContentDimensionsFromRootAndSitesNode($workspaceName, $dryRun) { $workspace = $this->workspaceRepository->findByIdentifier($workspaceName); $rootNodes = $this->nodeDataRepository->findByPath('/', $workspace); $sitesNodes = $this->nodeDataRepository->findByPath('/sites', $workspace); $this->output->outputLine('Checking for root and site nodes with content dimensions set ...'); /** @var \Neos\ContentRepository\Domain\Model\NodeData $rootNode */ foreach ($rootNodes as $rootNode) { if ($rootNode->getDimensionValues() !== []) { if ($dryRun === false) { $rootNode->setDimensions([]); $this->nodeDataRepository->update($rootNode); $this->output->outputLine('Removed content dimensions from root node'); } else { $this->output->outputLine('Found root node with content dimensions set.'); } } } /** @var \Neos\ContentRepository\Domain\Model\NodeData $sitesNode */ foreach ($sitesNodes as $sitesNode) { if ($sitesNode->getDimensionValues() !== []) { if ($dryRun === false) { $sitesNode->setDimensions([]); $this->nodeDataRepository->update($sitesNode); $this->output->outputLine('Removed content dimensions from node "/sites"'); } else { $this->output->outputLine('Found node "/sites"'); } } } }
/** * Removes all personal workspaces of the given user's account if these workspaces exist. Also removes * all possibly existing content of these workspaces. * * @param string $accountIdentifier Identifier of the user's account * @return void */ protected function deletePersonalWorkspace($accountIdentifier) { $userWorkspace = $this->workspaceRepository->findByIdentifier(UserUtility::getPersonalWorkspaceNameForUsername($accountIdentifier)); if ($userWorkspace instanceof Workspace) { $this->publishingService->discardAllNodes($userWorkspace); $this->workspaceRepository->remove($userWorkspace); } }
/** * Repair nodes whose shadow nodes are missing * * This check searches for nodes which have a corresponding node in one of the base workspaces, * have different node paths, but don't have a corresponding shadow node with a "movedto" value. * * @param string $workspaceName Currently ignored * @param boolean $dryRun Simulate? * @param NodeType $nodeType This argument will be ignored * @return void */ protected function repairShadowNodes($workspaceName, $dryRun, NodeType $nodeType = null) { /** @var Workspace $workspace */ $workspace = $this->workspaceRepository->findByIdentifier($workspaceName); if ($workspace->getBaseWorkspace() === null) { $this->output->outputLine('Repairing base workspace "%s", therefore skipping check for shadow nodes.', [$workspaceName]); $this->output->outputLine(); return; } $this->output->outputLine('Checking for nodes with missing shadow nodes ...'); $fixedShadowNodes = $this->fixShadowNodesInWorkspace($workspace, $nodeType); $this->output->outputLine('%s %s node%s with missing shadow nodes.', [$dryRun ? 'Would repair' : 'Repaired', $fixedShadowNodes, $fixedShadowNodes !== 1 ? 's' : '']); $this->output->outputLine(); }
/** * Returns the current workspace. * * @param boolean $createWorkspaceIfNecessary DEPRECATED: If enabled, creates a workspace with the configured name if it doesn't exist already. This option is DEPRECATED, create workspace explicitly instead. * @return Workspace The workspace or NULL * @api */ public function getWorkspace($createWorkspaceIfNecessary = true) { if ($this->workspace !== null) { return $this->workspace; } $this->workspace = $this->workspaceRepository->findByIdentifier($this->workspaceName); if ($this->workspace === null && $createWorkspaceIfNecessary) { $liveWorkspace = $this->workspaceRepository->findByIdentifier('live'); $this->workspace = new Workspace($this->workspaceName, $liveWorkspace); $this->workspaceRepository->add($this->workspace); $this->systemLogger->log(sprintf('Notice: %s::getWorkspace() implicitly created the new workspace "%s". This behaviour is discouraged and will be removed in future versions. Make sure to create workspaces explicitly by adding a new workspace to the Workspace Repository.', __CLASS__, $this->workspaceName), LOG_NOTICE); } if ($this->workspace !== null) { $this->validateWorkspace($this->workspace); } return $this->workspace; }
/** * Create a workspace * * @param string $workspaceName * @param Workspace $baseWorkspace * @param string $ownerAccountIdentifier * @return string */ public function createAction($workspaceName, Workspace $baseWorkspace, $ownerAccountIdentifier = null) { $existingWorkspace = $this->workspaceRepository->findByIdentifier($workspaceName); if ($existingWorkspace !== null) { $this->throwStatus(409, 'Workspace already exists', ''); } if ($ownerAccountIdentifier !== null) { $owner = $this->userService->getUser($ownerAccountIdentifier); if ($owner === null) { $this->throwStatus(422, 'Requested owner account does not exist', ''); } } else { $owner = null; } $workspace = new Workspace($workspaceName, $baseWorkspace, $owner); $this->workspaceRepository->add($workspace); $this->throwStatus(201, 'Workspace created', ''); }