-
-
Notifications
You must be signed in to change notification settings - Fork 135
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: Adjust to "serializable commands" #3881
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5fd8ab3
TASK: Adjust to "serializable commands"
bwaidelich 8619c77
TASK: Adjust to overhauled api of `CommandThatFailedDuringRebase`
mhsdesign e2ee696
TASK: Extract conflict information from event and not possibly intern…
mhsdesign c2e9f67
TASK: Adjust to rename `EventThatFailedDuringRebase` to `ConflictingE…
mhsdesign 9175b0e
TASK: Adjust to rename `EventThatFailedDuringRebase` to `ConflictingE…
mhsdesign 829645a
BUGFIX: No conflicts are shown
mhsdesign 33b9bac
TASK: Adjust to use `firstDimensionSpacePoint`
mhsdesign File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,24 +14,20 @@ | |
|
||
namespace Neos\Neos\Ui\Infrastructure\ContentRepository; | ||
|
||
use Neos\ContentRepository\Core\CommandHandler\CommandInterface; | ||
use Neos\ContentRepository\Core\ContentRepository; | ||
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; | ||
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; | ||
use Neos\ContentRepository\Core\Feature\NodeVariation\Command\CreateNodeVariant; | ||
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Command\TagSubtree; | ||
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Command\UntagSubtree; | ||
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\CommandThatFailedDuringRebase; | ||
use Neos\ContentRepository\Core\EventStore\EventInterface; | ||
use Neos\ContentRepository\Core\Feature\NodeCreation\Event\NodeAggregateWithNodeWasCreated; | ||
use Neos\ContentRepository\Core\Feature\NodeModification\Event\NodePropertiesWereSet; | ||
use Neos\ContentRepository\Core\Feature\NodeMove\Event\NodeAggregateWasMoved; | ||
use Neos\ContentRepository\Core\Feature\NodeReferencing\Event\NodeReferencesWereSet; | ||
use Neos\ContentRepository\Core\Feature\NodeRemoval\Event\NodeAggregateWasRemoved; | ||
use Neos\ContentRepository\Core\Feature\NodeTypeChange\Event\NodeAggregateTypeWasChanged; | ||
use Neos\ContentRepository\Core\Feature\NodeVariation\Event\NodeGeneralizationVariantWasCreated; | ||
use Neos\ContentRepository\Core\Feature\NodeVariation\Event\NodePeerVariantWasCreated; | ||
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Event\SubtreeWasTagged; | ||
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Event\SubtreeWasUntagged; | ||
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\ConflictingEvent; | ||
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Exception\WorkspaceRebaseFailed; | ||
use Neos\ContentRepository\Core\NodeType\NodeTypeManager; | ||
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface; | ||
|
@@ -80,9 +76,9 @@ public function fromWorkspaceRebaseFailed( | |
/** @var array<string,Conflict> */ | ||
$conflictsByKey = []; | ||
|
||
foreach ($workspaceRebaseFailed->commandsThatFailedDuringRebase as $commandThatFailedDuringRebase) { | ||
$conflict = $this->createConflictFromCommandThatFailedDuringRebase($commandThatFailedDuringRebase); | ||
if (array_key_exists($conflict->key, $conflictsByKey)) { | ||
foreach ($workspaceRebaseFailed->conflictingEvents as $conflictingEvent) { | ||
$conflict = $this->createConflict($conflictingEvent); | ||
if (!array_key_exists($conflict->key, $conflictsByKey)) { | ||
// deduplicate if the conflict affects the same node | ||
$conflictsByKey[$conflict->key] = $conflict; | ||
} | ||
|
@@ -91,14 +87,12 @@ public function fromWorkspaceRebaseFailed( | |
return new Conflicts(...$conflictsByKey); | ||
} | ||
|
||
private function createConflictFromCommandThatFailedDuringRebase( | ||
CommandThatFailedDuringRebase $commandThatFailedDuringRebase | ||
private function createConflict( | ||
ConflictingEvent $conflictingEvent | ||
): Conflict { | ||
$nodeAggregateId = $this->extractNodeAggregateIdFromCommand( | ||
$commandThatFailedDuringRebase->command | ||
); | ||
$subgraph = $this->acquireSubgraphFromCommand( | ||
$commandThatFailedDuringRebase->command, | ||
$nodeAggregateId = $conflictingEvent->getAffectedNodeAggregateId(); | ||
$subgraph = $this->acquireSubgraph( | ||
$conflictingEvent->getEvent(), | ||
$nodeAggregateId | ||
); | ||
$affectedSite = $nodeAggregateId | ||
|
@@ -130,67 +124,42 @@ private function createConflictFromCommandThatFailedDuringRebase( | |
affectedNode: $affectedNode | ||
? $this->createIconLabelForNode($affectedNode) | ||
: null, | ||
typeOfChange: $this->createTypeOfChangeFromCommand( | ||
$commandThatFailedDuringRebase->command | ||
typeOfChange: $this->createTypeOfChange( | ||
$conflictingEvent->getEvent() | ||
), | ||
reasonForConflict: $this->createReasonForConflictFromException( | ||
$commandThatFailedDuringRebase->exception | ||
$conflictingEvent->getException() | ||
) | ||
); | ||
} | ||
|
||
private function extractNodeAggregateIdFromCommand(CommandInterface $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( | ||
CommandInterface $command, | ||
private function acquireSubgraph( | ||
EventInterface $event, | ||
?NodeAggregateId $nodeAggregateIdForDimensionFallback | ||
): ?ContentSubgraphInterface { | ||
if ($this->workspace === null) { | ||
return null; | ||
} | ||
|
||
$dimensionSpacePoint = match (true) { | ||
$command instanceof MoveNodeAggregate => | ||
$command->dimensionSpacePoint, | ||
$command instanceof SetNodeProperties, | ||
$command instanceof SetSerializedNodeProperties, | ||
$command instanceof CreateNodeAggregateWithNode, | ||
$command instanceof CreateNodeAggregateWithNodeAndSerializedProperties => | ||
$command->originDimensionSpacePoint->toDimensionSpacePoint(), | ||
$command instanceof SetNodeReferences, | ||
$command instanceof SetSerializedNodeReferences => | ||
$command->sourceOriginDimensionSpacePoint->toDimensionSpacePoint(), | ||
$command instanceof TagSubtree, | ||
$command instanceof DisableNodeAggregate, | ||
$command instanceof UntagSubtree, | ||
$command instanceof EnableNodeAggregate, | ||
$command instanceof RemoveNodeAggregate => | ||
$command->coveredDimensionSpacePoint, | ||
$command instanceof ChangeNodeAggregateType => | ||
$dimensionSpacePoint = match ($event::class) { | ||
NodeAggregateWasMoved::class => | ||
$event->succeedingSiblingsForCoverage->toDimensionSpacePointSet()->getFirst(), | ||
NodePropertiesWereSet::class, | ||
NodeAggregateWithNodeWasCreated::class => | ||
$event->originDimensionSpacePoint->toDimensionSpacePoint(), | ||
NodeReferencesWereSet::class => | ||
$event->affectedSourceOriginDimensionSpacePoints->toDimensionSpacePointSet()->getFirst(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not ideal that there is only a set here and not a |
||
SubtreeWasTagged::class, | ||
SubtreeWasUntagged::class => | ||
$event->affectedDimensionSpacePoints->getFirst(), | ||
NodeAggregateWasRemoved::class => | ||
$event->affectedCoveredDimensionSpacePoints->getFirst(), | ||
NodeAggregateTypeWasChanged::class => | ||
null, | ||
$command instanceof CreateNodeVariant => | ||
$command->targetOrigin->toDimensionSpacePoint(), | ||
NodePeerVariantWasCreated::class => | ||
$event->peerOrigin->toDimensionSpacePoint(), | ||
NodeGeneralizationVariantWasCreated::class => | ||
$event->generalizationOrigin->toDimensionSpacePoint(), | ||
default => null | ||
}; | ||
|
||
|
@@ -247,27 +216,23 @@ private function createIconLabelForNode(Node $node): IconLabel | |
); | ||
} | ||
|
||
private function createTypeOfChangeFromCommand( | ||
CommandInterface $command | ||
private function createTypeOfChange( | ||
EventInterface $event | ||
): ?TypeOfChange { | ||
return match (true) { | ||
$command instanceof CreateNodeAggregateWithNode, | ||
$command instanceof CreateNodeAggregateWithNodeAndSerializedProperties, | ||
$command instanceof CreateNodeVariant => | ||
return match ($event::class) { | ||
NodeAggregateWithNodeWasCreated::class, | ||
NodePeerVariantWasCreated::class, | ||
NodeGeneralizationVariantWasCreated::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 => | ||
NodePropertiesWereSet::class, | ||
NodeReferencesWereSet::class, | ||
SubtreeWasTagged::class, | ||
SubtreeWasUntagged::class, | ||
NodeAggregateTypeWasChanged::class => | ||
TypeOfChange::NODE_HAS_BEEN_CHANGED, | ||
$command instanceof MoveNodeAggregate => | ||
NodeAggregateWasMoved::class => | ||
TypeOfChange::NODE_HAS_BEEN_MOVED, | ||
$command instanceof RemoveNodeAggregate => | ||
NodeAggregateWasRemoved::class => | ||
TypeOfChange::NODE_HAS_BEEN_DELETED, | ||
default => null | ||
}; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo this is maybe cheesy? We look into the
succeedingSiblingsForCoverage
???There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nasty.. I created an issue for that neos/neos-development-collection#5360