From daa1c362ec8984605467f012136e361044c0115a Mon Sep 17 00:00:00 2001 From: der_On Date: Tue, 2 Jul 2024 16:24:32 +0200 Subject: [PATCH] Also duplicates translated page contents fixes #43 --- controllers/Index.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/controllers/Index.php b/controllers/Index.php index 3b9d65d..1a11a0a 100644 --- a/controllers/Index.php +++ b/controllers/Index.php @@ -286,11 +286,7 @@ public function onDuplicateObject(): array $this->validateRequestTheme(); $type = $this->getObjectType(); - $object = ObjectHelper::loadObject( - $this->theme, - $type, - trim(Request::input('objectPath')) - ); + $object = $this->getObjectFromRequest(); $parentPage = null; $parent = null; @@ -306,9 +302,10 @@ public function onDuplicateObject(): array } } - $className = get_class($object); - $data = $object->toArray(); - $duplicatedObject = new $className($data); + // simply clone the entire object + $duplicatedObject = clone $object; + // must remove the file name or this page will not be unique + unset($duplicatedObject->fileName); $widget = $this->makeObjectFormWidget($type, $duplicatedObject); $this->vars['objectPath'] = '';