From 874e187f76b5dc0c79e028b829ab8d94ed932589 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 30 Oct 2024 21:59:17 +0100 Subject: [PATCH] TASK: Adjust to references changes in Neos --- Classes/Domain/Model/Changes/Property.php | 8 +++++++- ...PromotedElementsCreationHandlerFactory.php | 19 ++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Classes/Domain/Model/Changes/Property.php b/Classes/Domain/Model/Changes/Property.php index 93ece455dc..766754d0af 100644 --- a/Classes/Domain/Model/Changes/Property.php +++ b/Classes/Domain/Model/Changes/Property.php @@ -19,6 +19,7 @@ use Neos\ContentRepository\Core\Feature\NodeModification\Command\SetNodeProperties; use Neos\ContentRepository\Core\Feature\NodeModification\Dto\PropertyValuesToWrite; use Neos\ContentRepository\Core\Feature\NodeReferencing\Command\SetNodeReferences; +use Neos\ContentRepository\Core\Feature\NodeReferencing\Dto\NodeReferencesForName; use Neos\ContentRepository\Core\Feature\NodeReferencing\Dto\NodeReferencesToWrite; use Neos\ContentRepository\Core\Feature\NodeTypeChange\Command\ChangeNodeAggregateType; use Neos\ContentRepository\Core\Feature\NodeTypeChange\Dto\NodeAggregateTypeChangeChildConstraintConflictResolutionStrategy; @@ -239,7 +240,12 @@ private function handleNodeReferenceChange(Node $subject, string $propertyName): $subject->workspaceName, $subject->aggregateId, $subject->originDimensionSpacePoint, - NodeReferencesToWrite::fromNameAndTargets(ReferenceName::fromString($propertyName), NodeAggregateIds::fromArray($destinationNodeAggregateIds)) + NodeReferencesToWrite::fromReferences( + NodeReferencesForName::fromNameAndTargets( + ReferenceName::fromString($propertyName), + NodeAggregateIds::fromArray($destinationNodeAggregateIds) + ) + ) ) ); } diff --git a/Classes/Infrastructure/ContentRepository/CreationDialog/PromotedElementsCreationHandlerFactory.php b/Classes/Infrastructure/ContentRepository/CreationDialog/PromotedElementsCreationHandlerFactory.php index 996f4f3619..ba06077aa5 100644 --- a/Classes/Infrastructure/ContentRepository/CreationDialog/PromotedElementsCreationHandlerFactory.php +++ b/Classes/Infrastructure/ContentRepository/CreationDialog/PromotedElementsCreationHandlerFactory.php @@ -5,7 +5,7 @@ namespace Neos\Neos\Ui\Infrastructure\ContentRepository\CreationDialog; use Neos\ContentRepository\Core\ContentRepository; -use Neos\ContentRepository\Core\Feature\NodeReferencing\Dto\NodeReferencesToWrite; +use Neos\ContentRepository\Core\Feature\NodeReferencing\Dto\NodeReferencesForName; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIds; use Neos\ContentRepository\Core\SharedModel\Node\ReferenceName; @@ -38,7 +38,7 @@ public function handle(NodeCreationCommands $commands, NodeCreationElements $ele return $commands; } $propertyValues = $commands->first->initialPropertyValues; - $initialReferences = null; + $initialReferences = $commands->first->references; foreach ($elements as $elementName => $elementValue) { // handle properties if ($nodeType->hasProperty($elementName)) { @@ -56,18 +56,19 @@ public function handle(NodeCreationCommands $commands, NodeCreationElements $ele assert($elementValue instanceof NodeAggregateIds); $referenceConfiguration = $nodeType->getReferences()[$elementName]; if (($referenceConfiguration['ui']['showInCreationDialog'] ?? false) === true) { - $referencesToWriteForCurrentElement = NodeReferencesToWrite::fromNameAndTargets(ReferenceName::fromString($elementName), $elementValue); - $initialReferences = $initialReferences === null ? $referencesToWriteForCurrentElement : $initialReferences->merge($referencesToWriteForCurrentElement); + $initialReferences = $initialReferences->withReference( + NodeReferencesForName::fromNameAndTargets( + ReferenceName::fromString($elementName), + $elementValue + ) + ); } } } - if ($initialReferences !== null) { - $commands = $commands->withInitialReferences($initialReferences); - } - return $commands - ->withInitialPropertyValues($propertyValues); + ->withInitialPropertyValues($propertyValues) + ->withInitialReferences($initialReferences); } }; }