Neos\Neos\Controller\Service\WorkspacesController::createAction PHP Method

createAction() public method

Create a workspace
public createAction ( string $workspaceName, Workspace $baseWorkspace, string $ownerAccountIdentifier = null ) : string
$workspaceName string
$baseWorkspace Neos\ContentRepository\Domain\Model\Workspace
$ownerAccountIdentifier string
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', '');
    }