Skip to content

Commit

Permalink
Merge pull request #3775 from neos/task/adjustToWorkspaceAwareContent…
Browse files Browse the repository at this point in the history
…Graph

TASK: Adjust to workspace aware `ContentGraph`
  • Loading branch information
mhsdesign authored May 11, 2024
2 parents b8d1a20 + 0ab3aad commit 6c91e4e
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 32 deletions.
7 changes: 1 addition & 6 deletions Classes/Application/ReloadNodes/ReloadNodesQueryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,9 @@ final class ReloadNodesQueryHandler

public function handle(ReloadNodesQuery $query, ActionRequest $actionRequest): ReloadNodesQueryResult
{
$workspace = $this->workspaceProvider->provideForWorkspaceName(
$query->contentRepositoryId,
$query->workspaceName
);
$contentRepository = $this->contentRepositoryRegistry
->get($query->contentRepositoryId);
$subgraph = $contentRepository->getContentGraph()->getSubgraph(
$workspace->getCurrentContentStreamId(),
$subgraph = $contentRepository->getContentGraph($query->workspaceName)->getSubgraph(
$query->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
Expand Down
3 changes: 1 addition & 2 deletions Classes/ContentRepository/Service/NeosUiNodeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public function findNodeBySerializedNodeAddress(string $serializedNodeAddress, C
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
$nodeAddress = NodeAddressFactory::create($contentRepository)->createFromUriString($serializedNodeAddress);

$subgraph = $contentRepository->getContentGraph()->getSubgraph(
$nodeAddress->contentStreamId,
$subgraph = $contentRepository->getContentGraph($nodeAddress->workspaceName)->getSubgraph(
$nodeAddress->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
Expand Down
3 changes: 1 addition & 2 deletions Classes/ContentRepository/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo
'typeOfChange' => $this->getTypeOfChange($change)
];
} else {
$subgraph = $contentRepository->getContentGraph()->getSubgraph(
$workspace->currentContentStreamId,
$subgraph = $contentRepository->getContentGraph($workspaceName)->getSubgraph(
$change->originDimensionSpacePoint->toDimensionSpacePoint(),
VisibilityConstraints::withoutRestrictions()
);
Expand Down
17 changes: 9 additions & 8 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Exception\WorkspaceDoesNotExist;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ActionController;
Expand Down Expand Up @@ -146,10 +147,12 @@ public function indexAction(string $node = null)
}

$currentAccount = $this->securityContext->getAccount();
$workspace = $contentRepository->getWorkspaceFinder()->findOneByName(
WorkspaceNameBuilder::fromAccountIdentifier($currentAccount->getAccountIdentifier())
);
if (is_null($workspace)) {
$workspaceName = WorkspaceNameBuilder::fromAccountIdentifier($currentAccount->getAccountIdentifier());

try {
$contentGraph = $contentRepository->getContentGraph($workspaceName);
} catch (WorkspaceDoesNotExist) {
// todo will cause infinite loop: https://github.com/neos/neos-development-collection/issues/4401
$this->redirectToUri($this->uriBuilder->uriFor('index', [], 'Login', 'Neos.Neos'));
}

Expand All @@ -159,16 +162,14 @@ public function indexAction(string $node = null)
);
$defaultDimensionSpacePoint = $backendControllerInternals->getDefaultDimensionSpacePoint();

$subgraph = $contentRepository->getContentGraph()->getSubgraph(
$workspace->currentContentStreamId,
$subgraph = $contentGraph->getSubgraph(
$nodeAddress ? $nodeAddress->dimensionSpacePoint : $defaultDimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);

// we assume that the ROOT node is always stored in the CR as "physical" node; so it is safe
// to call the contentGraph here directly.
$rootNodeAggregate = $contentRepository->getContentGraph()->findRootNodeAggregateByType(
$workspace->currentContentStreamId,
$rootNodeAggregate = $contentGraph->findRootNodeAggregateByType(
NodeTypeNameFactory::forSites()
);
$rootNode = $rootNodeAggregate->getNodeByCoveredDimensionSpacePoint($defaultDimensionSpacePoint);
Expand Down
12 changes: 4 additions & 8 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,8 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, string $d
return;
}

$subgraph = $contentRepository->getContentGraph()
$subgraph = $contentRepository->getContentGraph($workspace->name)
->getSubgraph(
$workspace->getCurrentContentStreamId(),
$command->documentNode->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
Expand Down Expand Up @@ -540,8 +539,7 @@ public function getAdditionalNodeMetadataAction(array $nodes): void
$result = [];
foreach ($nodes as $nodeAddressString) {
$nodeAddress = $nodeAddressFactory->createFromUriString($nodeAddressString);
$subgraph = $contentRepository->getContentGraph()->getSubgraph(
$nodeAddress->contentStreamId,
$subgraph = $contentRepository->getContentGraph($nodeAddress->workspaceName)->getSubgraph(
$nodeAddress->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
Expand Down Expand Up @@ -587,8 +585,7 @@ public function getPolicyInformationAction(array $nodes): void

$result = [];
foreach ($nodes as $nodeAddress) {
$subgraph = $contentRepository->getContentGraph()->getSubgraph(
$nodeAddress->contentStreamId,
$subgraph = $contentRepository->getContentGraph($nodeAddress->workspaceName)->getSubgraph(
$nodeAddress->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
Expand Down Expand Up @@ -670,8 +667,7 @@ public function generateUriPathSegmentAction(string $contextNode, string $text):
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);

$contextNodeAddress = $nodeAddressFactory->createFromUriString($contextNode);
$subgraph = $contentRepository->getContentGraph()->getSubgraph(
$contextNodeAddress->contentStreamId,
$subgraph = $contentRepository->getContentGraph($contextNodeAddress->workspaceName)->getSubgraph(
$contextNodeAddress->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
Expand Down
3 changes: 1 addition & 2 deletions Classes/Domain/Model/Changes/CopyAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ public function apply(): void
throw new \Exception('Could not find workspace for content stream', 1699004343);
}
$command = CopyNodesRecursively::createFromSubgraphAndStartNode(
$contentRepository->getContentGraph()->getSubgraph(
$subject->subgraphIdentity->contentStreamId,
$contentRepository->getContentGraph($workspace->workspaceName)->getSubgraph(
$subject->subgraphIdentity->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
),
Expand Down
3 changes: 1 addition & 2 deletions Classes/Domain/Model/Changes/CopyBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ public function apply(): void
throw new \Exception('Could not find workspace for content stream', 1699004343);
}
$command = CopyNodesRecursively::createFromSubgraphAndStartNode(
$contentRepository->getContentGraph()->getSubgraph(
$subject->subgraphIdentity->contentStreamId,
$contentRepository->getContentGraph($workspace->workspaceName)->getSubgraph(
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->subgraphIdentity->visibilityConstraints
),
Expand Down
3 changes: 1 addition & 2 deletions Classes/Domain/Model/Changes/CopyInto.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ public function apply(): void
throw new \Exception('Could not find workspace for content stream', 1699004343);
}
$command = CopyNodesRecursively::createFromSubgraphAndStartNode(
$contentRepository->getContentGraph()->getSubgraph(
$subject->subgraphIdentity->contentStreamId,
$contentRepository->getContentGraph($workspace->workspaceName)->getSubgraph(
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->subgraphIdentity->visibilityConstraints
),
Expand Down

0 comments on commit 6c91e4e

Please sign in to comment.