Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK Refactor to not use content subgraph identity #3777

Merged
merged 3 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Classes/ContentRepository/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo
if ($node instanceof Node) {
$documentNode = $subgraph->findClosestNode($node->nodeAggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_DOCUMENT));
if ($documentNode instanceof Node) {
$contentRepository = $this->contentRepositoryRegistry->get($documentNode->subgraphIdentity->contentRepositoryId);
$contentRepository = $this->contentRepositoryRegistry->get($documentNode->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
$unpublishedNodes[] = [
'contextPath' => $nodeAddressFactory->createFromNode($node)->serializeForUri(),
Expand Down
10 changes: 2 additions & 8 deletions Classes/Domain/Model/AbstractChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,8 @@ protected function updateWorkspaceInfo(): void
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($this->subject);
$documentNode = $subgraph->findClosestNode($this->subject->nodeAggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_DOCUMENT));
if (!is_null($documentNode)) {
$contentRepository = $this->contentRepositoryRegistry->get($this->subject->subgraphIdentity->contentRepositoryId);
$workspace = $contentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId(
$documentNode->subgraphIdentity->contentStreamId
);
if (!is_null($workspace)) {
$updateWorkspaceInfo = new UpdateWorkspaceInfo($documentNode->subgraphIdentity->contentRepositoryId, $workspace->workspaceName);
$this->feedbackCollection->add($updateWorkspaceInfo);
}
$updateWorkspaceInfo = new UpdateWorkspaceInfo($documentNode->contentRepositoryId, $documentNode->workspaceName);
$this->feedbackCollection->add($updateWorkspaceInfo);
}
}
}
Expand Down
15 changes: 4 additions & 11 deletions Classes/Domain/Model/Changes/AbstractCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,13 @@ protected function createNode(

$nodeAggregateId = $this->getNodeAggregateId() ?? NodeAggregateId::create(); // generate a new NodeAggregateId

$contentRepository = $this->contentRepositoryRegistry->get($parentNode->subgraphIdentity->contentRepositoryId);
$workspace = $this->contentRepositoryRegistry->get($this->subject->subgraphIdentity->contentRepositoryId)
->getWorkspaceFinder()->findOneByCurrentContentStreamId($parentNode->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception(
'Could not find workspace for content stream "' . $parentNode->subgraphIdentity->contentStreamId->value . '"',
1699008140
);
}
$contentRepository = $this->contentRepositoryRegistry->get($parentNode->contentRepositoryId);

$command = CreateNodeAggregateWithNode::create(
$workspace->workspaceName,
$parentNode->workspaceName,
$nodeAggregateId,
$nodeTypeName,
OriginDimensionSpacePoint::fromDimensionSpacePoint($parentNode->subgraphIdentity->dimensionSpacePoint),
OriginDimensionSpacePoint::fromDimensionSpacePoint($parentNode->dimensionSpacePoint),
$parentNode->nodeAggregateId,
$succeedingSiblingNodeAggregateId,
$nodeName
Expand Down
6 changes: 3 additions & 3 deletions Classes/Domain/Model/Changes/AbstractStructuralChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getSiblingNode(): ?Node
if ($this->cachedSiblingNode === null) {
$this->cachedSiblingNode = $this->nodeService->findNodeBySerializedNodeAddress(
$this->siblingDomAddress->getContextPath(),
$this->getSubject()->subgraphIdentity->contentRepositoryId
$this->getSubject()->contentRepositoryId
);
}

Expand Down Expand Up @@ -155,7 +155,7 @@ protected function finish(Node $node)
// 1) the parent of our new (or copied or moved) node is a ContentCollection;
// so we can directly update an element of this content collection

$contentRepository = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId);
$contentRepository = $this->contentRepositoryRegistry->get($node->contentRepositoryId);
if ($parentNode && $this->getNodeType($parentNode)->isOfType('Neos.Neos:ContentCollection') &&
// 2) the parent DOM address (i.e. the closest RENDERED node in DOM is actually the ContentCollection;
// and no other node in between
Expand Down Expand Up @@ -195,7 +195,7 @@ protected function isNodeTypeAllowedAsChildNode(Node $node, NodeType $nodeType):

$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);
$parentNode = $subgraph->findParentNode($node->nodeAggregateId);
$nodeTypeManager = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId)->getNodeTypeManager();
$nodeTypeManager = $this->contentRepositoryRegistry->get($node->contentRepositoryId)->getNodeTypeManager();

return !$parentNode || $nodeTypeManager->isNodeTypeAllowedAsChildToTetheredNode(
$this->getNodeType($parentNode),
Expand Down
14 changes: 5 additions & 9 deletions Classes/Domain/Model/Changes/CopyAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,15 @@ public function apply(): void
// do nothing; $succeedingSibling is null.
}

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $contentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception('Could not find workspace for content stream', 1699004343);
}
$contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId);
$command = CopyNodesRecursively::createFromSubgraphAndStartNode(
$contentRepository->getContentGraph($workspace->workspaceName)->getSubgraph(
$subject->subgraphIdentity->dimensionSpacePoint,
$contentRepository->getContentGraph($subject->workspaceName)->getSubgraph(
$subject->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
),
$workspace->workspaceName,
$subject->workspaceName,
$subject,
OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->subgraphIdentity->dimensionSpacePoint),
OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->dimensionSpacePoint),
$parentNodeOfPreviousSibling->nodeAggregateId,
$succeedingSibling?->nodeAggregateId,
null
Expand Down
16 changes: 6 additions & 10 deletions Classes/Domain/Model/Changes/CopyBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,15 @@ public function apply(): void
if ($this->canApply() && !is_null($subject) && !is_null($succeedingSibling)
&& !is_null($parentNodeOfSucceedingSibling)
) {
$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $contentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception('Could not find workspace for content stream', 1699004343);
}
$contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId);
$command = CopyNodesRecursively::createFromSubgraphAndStartNode(
$contentRepository->getContentGraph($workspace->workspaceName)->getSubgraph(
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->subgraphIdentity->visibilityConstraints
$contentRepository->getContentGraph($subject->workspaceName)->getSubgraph(
$subject->dimensionSpacePoint,
$subject->visibilityConstraints
),
$workspace->workspaceName,
$subject->workspaceName,
$subject,
OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->subgraphIdentity->dimensionSpacePoint),
OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->dimensionSpacePoint),
$parentNodeOfSucceedingSibling->nodeAggregateId,
$succeedingSibling->nodeAggregateId,
null
Expand Down
16 changes: 6 additions & 10 deletions Classes/Domain/Model/Changes/CopyInto.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,15 @@ public function apply(): void
$subject = $this->getSubject();
$parentNode = $this->getParentNode();
if ($parentNode && $subject && $this->canApply()) {
$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $contentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception('Could not find workspace for content stream', 1699004343);
}
$contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId);
$command = CopyNodesRecursively::createFromSubgraphAndStartNode(
$contentRepository->getContentGraph($workspace->workspaceName)->getSubgraph(
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->subgraphIdentity->visibilityConstraints
$contentRepository->getContentGraph($subject->workspaceName)->getSubgraph(
$subject->dimensionSpacePoint,
$subject->visibilityConstraints
),
$workspace->workspaceName,
$subject->workspaceName,
$subject,
OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->subgraphIdentity->dimensionSpacePoint),
OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->dimensionSpacePoint),
$parentNode->nodeAggregateId,
null,
null
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Changes/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function canApply(): bool
{
$subject = $this->getSubject();
$nodeTypeName = $this->getNodeTypeName();
$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId);
$nodeType = $contentRepository->getNodeTypeManager()->getNodeType($nodeTypeName);

return $this->isNodeTypeAllowedAsChildNode($subject, $nodeType);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Changes/CreateAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function canApply(): bool
}
$parent = $this->findParentNode($this->subject);
$nodeTypeName = $this->getNodeTypeName();
$contentRepository = $this->contentRepositoryRegistry->get($parent->subgraphIdentity->contentRepositoryId);
$contentRepository = $this->contentRepositoryRegistry->get($parent->contentRepositoryId);
$nodeType = $contentRepository->getNodeTypeManager()->getNodeType($nodeTypeName);

return $this->isNodeTypeAllowedAsChildNode($parent, $nodeType);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Changes/CreateBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function canApply(): bool
}
$parent = $this->findParentNode($this->subject);
$nodeTypeName = $this->getNodeTypeName();
$contentRepository = $this->contentRepositoryRegistry->get($parent->subgraphIdentity->contentRepositoryId);
$contentRepository = $this->contentRepositoryRegistry->get($parent->contentRepositoryId);
$nodeType = $contentRepository->getNodeTypeManager()->getNodeType($nodeTypeName);

return $this->isNodeTypeAllowedAsChildNode($parent, $nodeType);
Expand Down
14 changes: 3 additions & 11 deletions Classes/Domain/Model/Changes/MoveAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,11 @@ public function apply(): void
->equals($parentNodeOfPreviousSibling->nodeAggregateId);


$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $this->contentRepositoryRegistry->get($this->subject->subgraphIdentity->contentRepositoryId)
->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception(
'Could not find workspace for content stream "' . $subject->subgraphIdentity->contentStreamId->value . '"',
1699008140
);
}
$contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId);

$command = MoveNodeAggregate::create(
$workspace->workspaceName,
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->workspaceName,
$subject->dimensionSpacePoint,
$subject->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL,
$hasEqualParentNode ? null : $parentNodeOfPreviousSibling->nodeAggregateId,
Expand Down
14 changes: 3 additions & 11 deletions Classes/Domain/Model/Changes/MoveBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,12 @@ public function apply(): void
$hasEqualParentNode = $parentNode->nodeAggregateId
->equals($succeedingSiblingParent->nodeAggregateId);

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $this->contentRepositoryRegistry->get($this->subject->subgraphIdentity->contentRepositoryId)
->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception(
'Could not find workspace for content stream "' . $subject->subgraphIdentity->contentStreamId->value . '"',
1699008140
);
}
$contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId);

$contentRepository->handle(
MoveNodeAggregate::create(
$workspace->workspaceName,
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->workspaceName,
$subject->dimensionSpacePoint,
$subject->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL,
$hasEqualParentNode
Expand Down
16 changes: 4 additions & 12 deletions Classes/Domain/Model/Changes/MoveInto.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getParentNode(): ?Node

return $this->nodeService->findNodeBySerializedNodeAddress(
$this->parentContextPath,
$this->getSubject()->subgraphIdentity->contentRepositoryId
$this->getSubject()->contentRepositoryId
);
}

Expand Down Expand Up @@ -82,19 +82,11 @@ public function apply(): void
$hasEqualParentNode = $otherParent && $otherParent->nodeAggregateId
->equals($parentNode->nodeAggregateId);

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $this->contentRepositoryRegistry->get($this->subject->subgraphIdentity->contentRepositoryId)
->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
throw new \Exception(
'Could not find workspace for content stream "' . $subject->subgraphIdentity->contentStreamId->value . '"',
1699008140
);
}
$contentRepository = $this->contentRepositoryRegistry->get($subject->contentRepositoryId);
$contentRepository->handle(
MoveNodeAggregate::create(
$workspace->workspaceName,
$subject->subgraphIdentity->dimensionSpacePoint,
$subject->workspaceName,
$subject->dimensionSpacePoint,
$subject->nodeAggregateId,
RelationDistributionStrategy::STRATEGY_GATHER_ALL,
$hasEqualParentNode ? null : $parentNode->nodeAggregateId,
Expand Down
Loading
Loading