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: Show changes to nodeAggregates for occupied nodes dimensionspacepoints #3878

Merged
merged 3 commits into from
Oct 24, 2024
Merged
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
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
Loading