Skip to content

Commit

Permalink
TASK: Adjust to overhauled api of CommandThatFailedDuringRebase
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Nov 9, 2024
1 parent 5fd8ab3 commit 8619c77
Showing 1 changed file with 28 additions and 62 deletions.
90 changes: 28 additions & 62 deletions Classes/Infrastructure/ContentRepository/ConflictsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
};
Expand Down Expand Up @@ -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
};
Expand Down

0 comments on commit 8619c77

Please sign in to comment.