From 8619c7729e815a590981840ab3e4ff60df300793 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Sat, 9 Nov 2024 11:27:40 +0100 Subject: [PATCH] TASK: Adjust to overhauled api of `CommandThatFailedDuringRebase` --- .../ContentRepository/ConflictsFactory.php | 90 ++++++------------- 1 file changed, 28 insertions(+), 62 deletions(-) diff --git a/Classes/Infrastructure/ContentRepository/ConflictsFactory.php b/Classes/Infrastructure/ContentRepository/ConflictsFactory.php index b63d5a1071..2af7051498 100644 --- a/Classes/Infrastructure/ContentRepository/ConflictsFactory.php +++ b/Classes/Infrastructure/ContentRepository/ConflictsFactory.php @@ -17,14 +17,11 @@ use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\Feature\Common\RebasableToOtherWorkspaceInterface; -use Neos\ContentRepository\Core\Feature\NodeCreation\Command\CreateNodeAggregateWithNode; use Neos\ContentRepository\Core\Feature\NodeCreation\Command\CreateNodeAggregateWithNodeAndSerializedProperties; use Neos\ContentRepository\Core\Feature\NodeDisabling\Command\DisableNodeAggregate; use Neos\ContentRepository\Core\Feature\NodeDisabling\Command\EnableNodeAggregate; -use Neos\ContentRepository\Core\Feature\NodeModification\Command\SetNodeProperties; use Neos\ContentRepository\Core\Feature\NodeModification\Command\SetSerializedNodeProperties; use Neos\ContentRepository\Core\Feature\NodeMove\Command\MoveNodeAggregate; -use Neos\ContentRepository\Core\Feature\NodeReferencing\Command\SetNodeReferences; use Neos\ContentRepository\Core\Feature\NodeReferencing\Command\SetSerializedNodeReferences; use Neos\ContentRepository\Core\Feature\NodeRemoval\Command\RemoveNodeAggregate; use Neos\ContentRepository\Core\Feature\NodeTypeChange\Command\ChangeNodeAggregateType; @@ -94,11 +91,9 @@ public function fromWorkspaceRebaseFailed( private function createConflictFromCommandThatFailedDuringRebase( CommandThatFailedDuringRebase $commandThatFailedDuringRebase ): Conflict { - $nodeAggregateId = $this->extractNodeAggregateIdFromCommand( - $commandThatFailedDuringRebase->command - ); + $nodeAggregateId = $commandThatFailedDuringRebase->getAffectedNodeAggregateId(); $subgraph = $this->acquireSubgraphFromCommand( - $commandThatFailedDuringRebase->command, + $commandThatFailedDuringRebase->getCommand(), $nodeAggregateId ); $affectedSite = $nodeAggregateId @@ -131,37 +126,14 @@ private function createConflictFromCommandThatFailedDuringRebase( ? $this->createIconLabelForNode($affectedNode) : null, typeOfChange: $this->createTypeOfChangeFromCommand( - $commandThatFailedDuringRebase->command + $commandThatFailedDuringRebase->getCommand() ), reasonForConflict: $this->createReasonForConflictFromException( - $commandThatFailedDuringRebase->exception + $commandThatFailedDuringRebase->getException() ) ); } - private function extractNodeAggregateIdFromCommand(RebasableToOtherWorkspaceInterface $command): ?NodeAggregateId - { - return match (true) { - $command instanceof MoveNodeAggregate, - $command instanceof SetNodeProperties, - $command instanceof SetSerializedNodeProperties, - $command instanceof CreateNodeAggregateWithNode, - $command instanceof CreateNodeAggregateWithNodeAndSerializedProperties, - $command instanceof TagSubtree, - $command instanceof DisableNodeAggregate, - $command instanceof UntagSubtree, - $command instanceof EnableNodeAggregate, - $command instanceof RemoveNodeAggregate, - $command instanceof ChangeNodeAggregateType, - $command instanceof CreateNodeVariant => - $command->nodeAggregateId, - $command instanceof SetNodeReferences, - $command instanceof SetSerializedNodeReferences => - $command->sourceNodeAggregateId, - default => null - }; - } - private function acquireSubgraphFromCommand( RebasableToOtherWorkspaceInterface $command, ?NodeAggregateId $nodeAggregateIdForDimensionFallback @@ -170,26 +142,23 @@ private function acquireSubgraphFromCommand( return null; } - $dimensionSpacePoint = match (true) { - $command instanceof MoveNodeAggregate => + $dimensionSpacePoint = match ($command::class) { + MoveNodeAggregate::class => $command->dimensionSpacePoint, - $command instanceof SetNodeProperties, - $command instanceof SetSerializedNodeProperties, - $command instanceof CreateNodeAggregateWithNode, - $command instanceof CreateNodeAggregateWithNodeAndSerializedProperties => + SetSerializedNodeProperties::class, + CreateNodeAggregateWithNodeAndSerializedProperties::class => $command->originDimensionSpacePoint->toDimensionSpacePoint(), - $command instanceof SetNodeReferences, - $command instanceof SetSerializedNodeReferences => + SetSerializedNodeReferences::class => $command->sourceOriginDimensionSpacePoint->toDimensionSpacePoint(), - $command instanceof TagSubtree, - $command instanceof DisableNodeAggregate, - $command instanceof UntagSubtree, - $command instanceof EnableNodeAggregate, - $command instanceof RemoveNodeAggregate => + TagSubtree::class, + DisableNodeAggregate::class, + UntagSubtree::class, + EnableNodeAggregate::class, + RemoveNodeAggregate::class => $command->coveredDimensionSpacePoint, - $command instanceof ChangeNodeAggregateType => + ChangeNodeAggregateType::class => null, - $command instanceof CreateNodeVariant => + CreateNodeVariant::class => $command->targetOrigin->toDimensionSpacePoint(), default => null }; @@ -250,24 +219,21 @@ private function createIconLabelForNode(Node $node): IconLabel private function createTypeOfChangeFromCommand( RebasableToOtherWorkspaceInterface $command ): ?TypeOfChange { - return match (true) { - $command instanceof CreateNodeAggregateWithNode, - $command instanceof CreateNodeAggregateWithNodeAndSerializedProperties, - $command instanceof CreateNodeVariant => + return match ($command::class) { + CreateNodeAggregateWithNodeAndSerializedProperties::class, + CreateNodeVariant::class => TypeOfChange::NODE_HAS_BEEN_CREATED, - $command instanceof SetNodeProperties, - $command instanceof SetSerializedNodeProperties, - $command instanceof SetNodeReferences, - $command instanceof SetSerializedNodeReferences, - $command instanceof TagSubtree, - $command instanceof DisableNodeAggregate, - $command instanceof UntagSubtree, - $command instanceof EnableNodeAggregate, - $command instanceof ChangeNodeAggregateType => + SetSerializedNodeProperties::class, + SetSerializedNodeReferences::class, + TagSubtree::class, + DisableNodeAggregate::class, + UntagSubtree::class, + EnableNodeAggregate::class, + ChangeNodeAggregateType::class => TypeOfChange::NODE_HAS_BEEN_CHANGED, - $command instanceof MoveNodeAggregate => + MoveNodeAggregate::class => TypeOfChange::NODE_HAS_BEEN_MOVED, - $command instanceof RemoveNodeAggregate => + RemoveNodeAggregate::class => TypeOfChange::NODE_HAS_BEEN_DELETED, default => null };