Skip to content

Commit

Permalink
[5.x] Append entry to structure tree directly when duplicating entry …
Browse files Browse the repository at this point in the history
…with root as parent
  • Loading branch information
Boefjim committed Jan 7, 2025
1 parent c2ed1ce commit 8268106
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/Actions/DuplicateEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,17 @@ private function duplicateEntry(Entry $original, ?string $origin = null)
});

if ($originalParent && $originalParent !== $original->id()) {
$entry->structure()
->in($original->locale())
->appendTo($originalParent->id(), $entry)
->save();
if ($entry->structure()->expectsRoot() && $entry->structure()->in($entry->locale())->root()['entry'] === $originalParent->id()) {
$entry->structure()
->in($original->locale())
->append($entry)
->save();
} else {
$entry->structure()
->in($original->locale())
->appendTo($originalParent->id(), $entry)
->save();
}
}

return $entry;
Expand All @@ -127,10 +134,6 @@ protected function getEntryParentFromStructure(Entry $entry)
return null;
}

if ($entry->structure()->expectsRoot() && $entry->structure()->in($entry->locale())->root()['entry'] === $parentEntry->id()) {
return null;
}

return $parentEntry;
}

Expand Down

0 comments on commit 8268106

Please sign in to comment.