Skip to content

Commit

Permalink
Merge pull request #3776 from neos/task/dontAddRandomNodeNamesOnCopyO…
Browse files Browse the repository at this point in the history
…rMove

TASK: Dont add useless node names on copy
  • Loading branch information
mhsdesign authored May 12, 2024
2 parents 6c91e4e + 21d3690 commit c8ba57e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
10 changes: 4 additions & 6 deletions Classes/Domain/Model/Changes/CopyAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ public function apply(): void
// do nothing; $succeedingSibling is null.
}

$targetNodeName = NodeName::fromString(uniqid('node-'));

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $contentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
Expand All @@ -85,14 +83,14 @@ public function apply(): void
OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->subgraphIdentity->dimensionSpacePoint),
$parentNodeOfPreviousSibling->nodeAggregateId,
$succeedingSibling?->nodeAggregateId,
$targetNodeName
null
);

$contentRepository->handle($command)->block();

$newlyCreatedNode = $this->contentRepositoryRegistry->subgraphForNode($parentNodeOfPreviousSibling)
->findNodeByPath(
$targetNodeName,
$parentNodeOfPreviousSibling->nodeAggregateId
->findNodeById(
$command->nodeAggregateIdMapping->getNewNodeAggregateId($subject->nodeAggregateId)
);
$this->finish($newlyCreatedNode);
// NOTE: we need to run "finish" before "addNodeCreatedFeedback"
Expand Down
10 changes: 4 additions & 6 deletions Classes/Domain/Model/Changes/CopyBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ public function apply(): void
if ($this->canApply() && !is_null($subject) && !is_null($succeedingSibling)
&& !is_null($parentNodeOfSucceedingSibling)
) {
$targetNodeName = NodeName::fromString(uniqid('node-'));

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $contentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
Expand All @@ -78,14 +76,14 @@ public function apply(): void
OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->subgraphIdentity->dimensionSpacePoint),
$parentNodeOfSucceedingSibling->nodeAggregateId,
$succeedingSibling->nodeAggregateId,
$targetNodeName
null
);

$contentRepository->handle($command)->block();

$newlyCreatedNode = $this->contentRepositoryRegistry->subgraphForNode($parentNodeOfSucceedingSibling)
->findNodeByPath(
$targetNodeName,
$parentNodeOfSucceedingSibling->nodeAggregateId
->findNodeById(
$command->nodeAggregateIdMapping->getNewNodeAggregateId($subject->nodeAggregateId)
);
$this->finish($newlyCreatedNode);
// NOTE: we need to run "finish" before "addNodeCreatedFeedback"
Expand Down
9 changes: 3 additions & 6 deletions Classes/Domain/Model/Changes/CopyInto.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ public function apply(): void
$subject = $this->getSubject();
$parentNode = $this->getParentNode();
if ($parentNode && $subject && $this->canApply()) {
$targetNodeName = NodeName::fromString(uniqid('node-'));

$contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId);
$workspace = $contentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId($subject->subgraphIdentity->contentStreamId);
if (!$workspace) {
Expand All @@ -86,14 +84,13 @@ public function apply(): void
OriginDimensionSpacePoint::fromDimensionSpacePoint($subject->subgraphIdentity->dimensionSpacePoint),
$parentNode->nodeAggregateId,
null,
$targetNodeName
null
);
$contentRepository->handle($command)->block();

$newlyCreatedNode = $this->contentRepositoryRegistry->subgraphForNode($parentNode)
->findNodeByPath(
$targetNodeName,
$parentNode->nodeAggregateId
->findNodeById(
$command->nodeAggregateIdMapping->getNewNodeAggregateId($subject->nodeAggregateId),
);
$this->finish($newlyCreatedNode);
// NOTE: we need to run "finish" before "addNodeCreatedFeedback"
Expand Down

0 comments on commit c8ba57e

Please sign in to comment.