Skip to content
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

Adjustments to new Reference DTOs #3844

Merged
merged 4 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Classes/Domain/Model/Changes/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -239,8 +240,12 @@ private function handleNodeReferenceChange(Node $subject, string $propertyName):
$subject->workspaceName,
$subject->aggregateId,
$subject->originDimensionSpacePoint,
ReferenceName::fromString($propertyName),
NodeReferencesToWrite::fromNodeAggregateIds(NodeAggregateIds::fromArray($destinationNodeAggregateIds))
NodeReferencesToWrite::fromReferences(
NodeReferencesForName::fromNameAndTargets(
ReferenceName::fromString($propertyName),
NodeAggregateIds::fromArray($destinationNodeAggregateIds)
)
)
)
);
}
Expand Down
9 changes: 9 additions & 0 deletions Classes/Domain/NodeCreation/NodeCreationCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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\NodeReferencesToWrite;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;

/**
Expand Down Expand Up @@ -107,6 +108,14 @@ public function withInitialPropertyValues(PropertyValuesToWrite $newInitialPrope
);
}

public function withInitialReferences(NodeReferencesToWrite $newInitialReferences): self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice :D

{
return new self(
$this->first->withReferences($newInitialReferences),
...$this->additionalCommands
);
}

public function withAdditionalCommands(
CreateNodeAggregateWithNode|SetNodeProperties|DisableNodeAggregate|EnableNodeAggregate|SetNodeReferences|CopyNodesRecursively ...$additionalCommands
): self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
namespace Neos\Neos\Ui\Infrastructure\ContentRepository\CreationDialog;

use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\Feature\NodeReferencing\Command\SetNodeReferences;
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;
Expand Down Expand Up @@ -39,7 +38,7 @@ public function handle(NodeCreationCommands $commands, NodeCreationElements $ele
return $commands;
}
$propertyValues = $commands->first->initialPropertyValues;
$setReferencesCommands = [];
$initialReferences = $commands->first->references;
foreach ($elements as $elementName => $elementValue) {
// handle properties
if ($nodeType->hasProperty($elementName)) {
Expand All @@ -56,24 +55,20 @@ public function handle(NodeCreationCommands $commands, NodeCreationElements $ele
if ($nodeType->hasReference($elementName)) {
assert($elementValue instanceof NodeAggregateIds);
$referenceConfiguration = $nodeType->getReferences()[$elementName];
if (
($referenceConfiguration['ui']['showInCreationDialog'] ?? false) === true
) {
// a promoted element
$setReferencesCommands[] = SetNodeReferences::create(
$commands->first->workspaceName,
$commands->first->nodeAggregateId,
$commands->first->originDimensionSpacePoint,
ReferenceName::fromString($elementName),
NodeReferencesToWrite::fromNodeAggregateIds($elementValue)
if (($referenceConfiguration['ui']['showInCreationDialog'] ?? false) === true) {
$initialReferences = $initialReferences->withReference(
NodeReferencesForName::fromNameAndTargets(
ReferenceName::fromString($elementName),
$elementValue
)
);
}
}
}

return $commands
->withInitialPropertyValues($propertyValues)
->withAdditionalCommands(...$setReferencesCommands);
->withInitialReferences($initialReferences);
}
};
}
Expand Down
Loading