Skip to content

Commit

Permalink
Merge pull request #3878 from dlubitz/90/task/show-nodeaggregate-changes
Browse files Browse the repository at this point in the history
TASK: Show changes to nodeAggregates for occupied nodes dimensionspacepoints
  • Loading branch information
dlubitz authored Oct 24, 2024
2 parents 92d2705 + b3bafcc commit d7c53de
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions Classes/ContentRepository/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Neos\Neos\Ui\ContentRepository\Service;

/*
Expand All @@ -14,8 +15,8 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindClosestNodeFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
Expand Down Expand Up @@ -51,11 +52,12 @@ class WorkspaceService
public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepositoryId $contentRepositoryId): array
{
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
$contentGraph = $contentRepository->getContentGraph($workspaceName);
$pendingChanges = $this->workspacePublishingService->pendingWorkspaceChanges($contentRepositoryId, $workspaceName);
/** @var array{contextPath:string,documentContextPath:string,typeOfChange:int}[] $unpublishedNodes */
$unpublishedNodes = [];
foreach ($pendingChanges as $change) {
if ($change->removalAttachmentPoint) {
if ($change->removalAttachmentPoint && $change->originDimensionSpacePoint !== null) {
$nodeAddress = NodeAddress::create(
$contentRepositoryId,
$workspaceName,
Expand All @@ -79,20 +81,31 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo
'typeOfChange' => $this->getTypeOfChange($change)
];
} else {
$subgraph = $contentRepository->getContentGraph($workspaceName)->getSubgraph(
$change->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)
];
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 ?: [];
}

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)
];
}
}
}
}
Expand Down

0 comments on commit d7c53de

Please sign in to comment.