Skip to content

Commit

Permalink
TASK: Adjust to removed removalAttachmentPoint
Browse files Browse the repository at this point in the history
neos: 316bf261a9448a612b0d6644eeb4de951763730f
  • Loading branch information
mhsdesign committed Feb 14, 2025
1 parent ef0d6af commit 577a067
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 48 deletions.
69 changes: 21 additions & 48 deletions Classes/ContentRepository/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,61 +57,34 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo
/** @var array{contextPath:string,documentContextPath:string,typeOfChange:int}[] $unpublishedNodes */
$unpublishedNodes = [];
foreach ($pendingChanges as $change) {
if ($change->removalAttachmentPoint && $change->originDimensionSpacePoint !== null) {
$nodeAddress = NodeAddress::create(
$contentRepositoryId,
$workspaceName,
$change->originDimensionSpacePoint->toDimensionSpacePoint(),
$change->nodeAggregateId
);

/**
* See {@see Remove::apply} -> Removal Attachment Point == closest document node.
*/
$documentNodeAddress = NodeAddress::create(
$contentRepositoryId,
$workspaceName,
$change->originDimensionSpacePoint->toDimensionSpacePoint(),
$change->removalAttachmentPoint
);

$unpublishedNodes[] = [
'contextPath' => $nodeAddress->toJson(),
'documentContextPath' => $documentNodeAddress->toJson(),
'typeOfChange' => $this->getTypeOfChange($change)
];
if ($change->originDimensionSpacePoint !== null) {
$originDimensionSpacePoints = [$change->originDimensionSpacePoint];
} else {
if ($change->originDimensionSpacePoint !== null) {
$originDimensionSpacePoints = [$change->originDimensionSpacePoint];
} else {
// If originDimensionSpacePoint is null, we have a change to the nodeAggregate. All nodes in the
// occupied dimensionspacepoints shall be marked as changed.
$originDimensionSpacePoints = $contentGraph
->findNodeAggregateById($change->nodeAggregateId)
?->occupiedDimensionSpacePoints ?: [];
}
// If originDimensionSpacePoint is null, we have a change to the nodeAggregate. All nodes in the
// occupied dimensionspacepoints shall be marked as changed.
$originDimensionSpacePoints = $contentGraph
->findNodeAggregateById($change->nodeAggregateId)
?->occupiedDimensionSpacePoints ?: [];
}

$contentGraph = $contentRepository->getContentGraph($workspaceName);
foreach ($originDimensionSpacePoints as $originDimensionSpacePoint) {
$subgraph = $contentGraph->getSubgraph($originDimensionSpacePoint->toDimensionSpacePoint(), VisibilityConstraints::withoutRestrictions());
$node = $subgraph->findNodeById($change->nodeAggregateId);
if ($node instanceof Node) {
$documentNode = $subgraph->findClosestNode($node->aggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_DOCUMENT));
if ($documentNode instanceof Node) {
$unpublishedNodes[] = [
'contextPath' => NodeAddress::fromNode($node)->toJson(),
'documentContextPath' => NodeAddress::fromNode($documentNode)->toJson(),
'typeOfChange' => $this->getTypeOfChange($change)
];
}
$contentGraph = $contentRepository->getContentGraph($workspaceName);
foreach ($originDimensionSpacePoints as $originDimensionSpacePoint) {
$subgraph = $contentGraph->getSubgraph($originDimensionSpacePoint->toDimensionSpacePoint(), VisibilityConstraints::withoutRestrictions());
$node = $subgraph->findNodeById($change->nodeAggregateId);
if ($node instanceof Node) {
$documentNode = $subgraph->findClosestNode($node->aggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_DOCUMENT));
if ($documentNode instanceof Node) {
$unpublishedNodes[] = [
'contextPath' => NodeAddress::fromNode($node)->toJson(),
'documentContextPath' => NodeAddress::fromNode($documentNode)->toJson(),
'typeOfChange' => $this->getTypeOfChange($change)
];
}
}
}
}

return array_values(array_filter($unpublishedNodes, function ($item) {
return (bool)$item;
}));
return $unpublishedNodes;
}

private function getTypeOfChange(Change $change): int
Expand Down
2 changes: 2 additions & 0 deletions Classes/Domain/Model/Changes/Remove.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public function apply(): void
// otherwise we cannot find the parent nodes anymore.
$this->updateWorkspaceInfo();

// Issuing 'real' deletions via 'RemoveNodeAggregate' on a non-live workspace are not desired in Neos
// as these changes are not correctly publishable via the neos ui. Instead, we must use tagging to soft-delete nodes.
$command = TagSubtree::create(
$subject->workspaceName,
$subject->aggregateId,
Expand Down

0 comments on commit 577a067

Please sign in to comment.