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;
    }