Skip to content

Commit

Permalink
Forward contentGraph workspace name to events
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaidelich committed May 17, 2024
1 parent f4d2f41 commit 02624aa
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ protected function createEventsForMissingTetheredNode(
$rootGeneralizationOrigin = OriginDimensionSpacePoint::fromDimensionSpacePoint($rootGeneralization);
if ($creationOriginDimensionSpacePoint) {
$events[] = new NodePeerVariantWasCreated(
WorkspaceName::fromString('todo'), // TODO read from $parentNodeAggregate
$parentNodeAggregate->contentStreamId,
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$tetheredNodeAggregateId,
$creationOriginDimensionSpacePoint,
$rootGeneralizationOrigin,
Expand All @@ -90,8 +90,8 @@ protected function createEventsForMissingTetheredNode(
);
} else {
$events[] = new NodeAggregateWithNodeWasCreated(
WorkspaceName::fromString('todo'), // TODO read from $parentNodeAggregate
$parentNodeAggregate->contentStreamId,
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$tetheredNodeAggregateId,
$expectedTetheredNodeType->name,
$rootGeneralizationOrigin,
Expand All @@ -110,8 +110,8 @@ protected function createEventsForMissingTetheredNode(
}
return Events::with(
new NodeAggregateWithNodeWasCreated(
WorkspaceName::fromString('todo'), // TODO read from $parentNodeAggregate
$parentNodeAggregate->contentStreamId,
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$tetheredNodeAggregateId ?: NodeAggregateId::create(),
$expectedTetheredNodeType->name,
$originDimensionSpacePoint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ private function deleteDisallowedNodesWhenChangingNodeType(
);
// AND REMOVE THEM
$events[] = $this->removeNodeInDimensionSpacePointSet(
$contentGraph,
$childNodeAggregate,
$dimensionSpacePointsToBeRemoved,
);
Expand Down Expand Up @@ -336,6 +337,7 @@ private function deleteDisallowedNodesWhenChangingNodeType(
);
// AND REMOVE THEM
$events[] = $this->removeNodeInDimensionSpacePointSet(
$contentGraph,
$grandchildNodeAggregate,
$dimensionSpacePointsToBeRemoved,
);
Expand Down Expand Up @@ -369,6 +371,7 @@ private function deleteObsoleteTetheredNodesWhenChangingNodeType(
);
// AND REMOVE THEM
$events[] = $this->removeNodeInDimensionSpacePointSet(
$contentGraph,
$tetheredNodeAggregate,
$dimensionSpacePointsToBeRemoved,
);
Expand Down Expand Up @@ -423,12 +426,13 @@ private function findDimensionSpacePointsConnectingParentAndChildAggregate(
}

private function removeNodeInDimensionSpacePointSet(
ContentGraphInterface $contentGraph,
NodeAggregate $nodeAggregate,
DimensionSpacePointSet $coveredDimensionSpacePointsToBeRemoved,
): NodeAggregateWasRemoved {
return new NodeAggregateWasRemoved(
WorkspaceName::fromString('todo'), // TODO read from $nodeAggregate
$nodeAggregate->contentStreamId,
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$nodeAggregate->nodeAggregateId,
// TODO: we also use the covered dimension space points as OCCUPIED dimension space points
// - however the OCCUPIED dimension space points are not really used by now
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ private function removeNodeInSingleDimensionSpacePoint(
$referenceOrigin = OriginDimensionSpacePoint::fromDimensionSpacePoint($dimensionSpacePoint);
$events = Events::with(
new NodeAggregateWasRemoved(
WorkspaceName::fromString('todo'), // TODO read from $nodeAggregate
$nodeAggregate->contentStreamId,
$this->projectedNodeIterator->contentGraph->getWorkspaceName(),
$this->projectedNodeIterator->contentGraph->getContentStreamId(),
$nodeAggregate->nodeAggregateId,
$nodeAggregate->occupiesDimensionSpacePoint($referenceOrigin)
? new OriginDimensionSpacePointSet([$referenceOrigin])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private function publishNodePropertiesWereSet(
): EventsToPublish {
$events = Events::with(
new NodePropertiesWereSet(
WorkspaceName::fromString('todo'), // TODO read from $node
$node->workspaceName,
$node->subgraphIdentity->contentStreamId,
$node->nodeAggregateId,
$node->originDimensionSpacePoint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
use Neos\ContentRepository\Core\EventStore\EventsToPublish;
use Neos\ContentRepository\Core\Feature\ContentStreamEventStreamName;
use Neos\ContentRepository\Core\Feature\NodeRemoval\Event\NodeAggregateWasRemoved;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\EventStore\Model\EventStream\ExpectedVersion;

trait RemoveNodeAggregateTrait
{
private function removeNodeAggregate(NodeAggregate $tetheredNodeAggregate): EventsToPublish
private function removeNodeAggregate(ContentGraphInterface $contentGraph, NodeAggregate $tetheredNodeAggregate): EventsToPublish
{
$events = Events::with(
new NodeAggregateWasRemoved(
WorkspaceName::fromString('todo'), // TODO read from $tetheredNodeAggregate
$tetheredNodeAggregate->contentStreamId,
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$tetheredNodeAggregate->nodeAggregateId,
$tetheredNodeAggregate->occupiedDimensionSpacePoints,
$tetheredNodeAggregate->coveredDimensionSpacePoints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function () use ($nodeAggregate, $originDimensionSpacePoint, $tetheredNodeName,
'The tethered child node "'
. $tetheredNodeAggregate->nodeName->value . '" should be removed.',
function () use ($tetheredNodeAggregate) {
return $this->removeNodeAggregate($tetheredNodeAggregate);
return $this->removeNodeAggregate($this->projectedNodeIterator->contentGraph, $tetheredNodeAggregate);
}
);
}
Expand Down Expand Up @@ -154,8 +154,8 @@ function () use ($tetheredNodeAggregate) {
. ' - actual: '
. implode(', ', array_keys($actualTetheredChildNodes)),
fn () => $this->reorderNodes(
WorkspaceName::fromString('todo'), // TODO read from $nodeAggregate
$nodeAggregate->contentStreamId,
$this->projectedNodeIterator->contentGraph->getWorkspaceName(),
$this->projectedNodeIterator->contentGraph->getContentStreamId(),
$nodeAggregate->getCoverageByOccupant($originDimensionSpacePoint),
$actualTetheredChildNodes,
array_keys($expectedTetheredNodes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private function removeAllNodesOfType(NodeTypeName $nodeTypeName): \Generator
'The node type "' . $nodeTypeName->value
. '" is not found; so the node should be removed (or converted)',
function () use ($nodeAggregate) {
return $this->removeNodeAggregate($nodeAggregate);
return $this->removeNodeAggregate($this->projectedNodeIterator->contentGraph, $nodeAggregate);
}
);
}
Expand Down

0 comments on commit 02624aa

Please sign in to comment.