Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,44 @@ public function cloneObject(int $target_id, int $copy_id = 0, bool $omit_tree =
}

// copy content
$new_obj->populateByDirectoy($this->getDataDirectory());
$this->cloneContainerResource($new_obj);

// copy legacy content (only relevant for not yet migrated modules)
if (is_dir($this->getDataDirectory())) {
$new_obj->populateByDirectoy($this->getDataDirectory());
}

$new_obj->setStartFile((string) $this->getStartFile());
$new_obj->update();

return $new_obj;
}

/**
* Replace the empty container resource of the target object (created in
* ilObjFileBasedLM::create()) by a clone of this object's container.
*/
protected function cloneContainerResource(ilObjFileBasedLM $new_obj): void
{
$source = $this->getResource();
if ($source === null) {
return;
}

$target = $new_obj->getResource();
if ($target !== null) {
$this->irss->manageContainer()->remove(
$target->getIdentification(),
new ilHTLMStakeholder()
);
}

$cloned_rid = $this->irss->manageContainer()->clone(
$source->getIdentification()
);
$new_obj->setRID($cloned_rid->serialize());
}

public function isInfoEnabled(): bool
{
return ilObjContentObjectAccess::isInfoEnabled($this->getId());
Expand Down
Loading