Neos.ContentRepository/Classes/Domain/Service/Context.php
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->notice(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), LogEnvironment::fromMethodName(__METHOD__));
        }

        if ($this->workspace !== null) {
            $this->validateWorkspace($this->workspace);
        }

        return $this->workspace;
    }
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->notice(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), LogEnvironment::fromMethodName(__METHOD__));
        }

        if ($this->workspace !== null) {
            $this->validateWorkspace($this->workspace);
        }

        return $this->workspace;
    }
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 -> notice ( 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 ) , LogEnvironment :: fromMethodName ( __METHOD__ ) ) ; } if ( $ this -> workspace !== null ) { $ this -> validateWorkspace ( $ this -> workspace ) ; } return $ this -> workspace ; }
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
@throws IllegalObjectTypeException
Returns the current workspace .