Neos\Neos\Service\BackendRedirectionService::createWorkspaceAndRootNodeIfNecessary PHP Метод

createWorkspaceAndRootNodeIfNecessary() защищенный Метод

This method is basically a safeguard for legacy and potentially broken websites where users might not have their own workspace yet. In a normal setup, the Domain User Service is responsible for creating and deleting user workspaces.
protected createWorkspaceAndRootNodeIfNecessary ( string $workspaceName ) : void
$workspaceName string Name of the workspace
Результат void
    protected function createWorkspaceAndRootNodeIfNecessary($workspaceName)
    {
        $workspace = $this->workspaceRepository->findOneByName($workspaceName);
        if ($workspace === null) {
            $liveWorkspace = $this->workspaceRepository->findOneByName('live');
            $owner = $this->userService->getBackendUser();
            $workspace = new Workspace($workspaceName, $liveWorkspace, $owner);
            $this->workspaceRepository->add($workspace);
            $this->persistenceManager->whitelistObject($workspace);
        }
        $contentContext = $this->createContext($workspaceName);
        $rootNode = $contentContext->getRootNode();
        $this->persistenceManager->whitelistObject($rootNode);
        $this->persistenceManager->whitelistObject($rootNode->getNodeData());
        $this->persistenceManager->persistAll(true);
    }