Skip to content

Commit

Permalink
Remove WorkspaceNameBuilder usages
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaidelich committed Sep 27, 2024
1 parent a398e65 commit 8b4ed98
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Neos\Flow\Security\Context;
use Neos\Neos\Domain\Service\WorkspaceNameBuilder;
use Neos\Neos\Domain\Service\WorkspacePublishingService;
use Neos\Neos\Domain\Service\WorkspaceService;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
Expand Down Expand Up @@ -128,6 +129,12 @@ class BackendServiceController extends ActionController
*/
protected $nodeUriPathSegmentGenerator;

/**
* @Flow\Inject
* @var WorkspaceService
*/
protected $workspaceService;

/**
* @Flow\Inject
* @var WorkspacePublishingService
Expand Down Expand Up @@ -390,28 +397,26 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, string $d

$nodeAddressFactory = NodeAddressFactory::create($contentRepository);

$currentAccount = $this->securityContext->getAccount();
if ($currentAccount === null) {
$user = $this->userService->getBackendUser();
if ($user === null) {
$error = new Error();
$error->setMessage('No authenticated account');
$this->feedbackCollection->add($error);
$this->view->assign('value', $this->feedbackCollection);
return;
}
$userWorkspaceName = WorkspaceNameBuilder::fromAccountIdentifier(
$currentAccount->getAccountIdentifier()
);
$userWorkspace = $this->workspaceService->getPersonalWorkspaceForUser($contentRepositoryId, $user->getId());

/** @todo send from UI */
$command = new ChangeTargetWorkspace(
$contentRepositoryId,
$userWorkspaceName,
$userWorkspace->workspaceName,
WorkspaceName::fromString($targetWorkspaceName),
$nodeAddressFactory->createFromUriString($documentNode)
);

try {
$this->workspacePublishingService->changeBaseWorkspace($contentRepositoryId, $userWorkspaceName, WorkspaceName::fromString($targetWorkspaceName));
$this->workspacePublishingService->changeBaseWorkspace($contentRepositoryId, $userWorkspace->workspaceName, WorkspaceName::fromString($targetWorkspaceName));
} catch (WorkspaceIsNotEmptyException $exception) {
$error = new Error();
$error->setMessage(
Expand All @@ -430,7 +435,7 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, string $d
return;
}

$subgraph = $contentRepository->getContentGraph($userWorkspaceName)
$subgraph = $contentRepository->getContentGraph($userWorkspace->workspaceName)
->getSubgraph(
$command->documentNode->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
Expand All @@ -445,7 +450,7 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, string $d
);
$this->feedbackCollection->add($success);

$updateWorkspaceInfo = new UpdateWorkspaceInfo($contentRepositoryId, $userWorkspaceName);
$updateWorkspaceInfo = new UpdateWorkspaceInfo($contentRepositoryId, $userWorkspace->workspaceName);
$this->feedbackCollection->add($updateWorkspaceInfo);

// If current document node doesn't exist in the base workspace,
Expand Down

0 comments on commit 8b4ed98

Please sign in to comment.