Skip to content

Commit

Permalink
Export: Build export target with export object instead of obj id for …
Browse files Browse the repository at this point in the history
…standard and container export
  • Loading branch information
chlulei committed Feb 10, 2025
1 parent 59bdcb3 commit e63f595
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use ILIAS\Export\ExportHandler\I\Info\Export\Container\ObjectId\CollectionInterface as ilExportHandlerContainerExportInfoObjectIdCollectionInterface;
use ILIAS\Export\ExportHandler\I\Info\Export\HandlerInterface as ilExportHandlerExportInfoInterface;
use ILIAS\Export\ExportHandler\I\Repository\Element\HandlerInterface as ilExportHandlerRepositoryElementInterface;
use ilObject;

interface HandlerInterface
{
Expand All @@ -46,6 +47,11 @@ public function getExportInfo(
int $time_stamp
): ilExportHandlerExportInfoInterface;

public function getExportInfoWithObject(
ilObject $export_object,
int $time_stamp
): ilExportHandlerExportInfoInterface;

public function getContainerExportInfo(
ObjectId $main_entity_object_id,
ilExportHandlerContainerExportInfoObjectIdCollectionInterface $object_ids
Expand Down
25 changes: 25 additions & 0 deletions components/ILIAS/Export/classes/ExportHandler/Manager/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ public function __construct(
$this->data_factory_wrapper = $data_factory_wrapper;
}

protected function getExportTargetWithObject(
ilObject $export_object
) {
$obj_id = $export_object->getId();
$type = $export_object->getType();
$class = ilImportExportFactory::getExporterClass($type);
$comp = ilImportExportFactory::getComponentForExport($type);
$v = explode(".", ILIAS_VERSION_NUMERIC);
$target_release = $v[0] . "." . $v[1] . ".0";
return $this->export_handler->target()->handler()
->withTargetRelease($target_release)
->withType($type)
->withObjectIds([$obj_id])
->withClassname($class)
->withComponent($comp);
}

protected function getExportTarget(
ObjectId $object_id
): ilExportHandlerTargetInterface {
Expand Down Expand Up @@ -190,6 +207,14 @@ public function getExportInfo(
->withTarget($this->getExportTarget($object_id), $time_stamp);
}

public function getExportInfoWithObject(
ilObject $export_object,
int $time_stamp
): ilExportHandlerExportInfoInterface {
return $this->export_handler->info()->export()->handler()
->withTarget($this->getExportTargetWithObject($export_object), $time_stamp);
}

public function getContainerExportInfo(
ObjectId $main_entity_object_id,
ilExportHandlerContainerExportInfoObjectIdCollectionInterface $object_ids
Expand Down
8 changes: 4 additions & 4 deletions components/ILIAS/Export/classes/class.ilExportGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ final protected function saveItemSelection(): void
final protected function createXMLExport()
{
$manager = $this->export_handler->manager()->handler();
$export_info = $manager->getExportInfo(
$this->data_factory->objId($this->obj->getId()),
$export_info = $manager->getExportInfoWithObject(
$this->obj,
time()
);
$element = $manager->createExport(
Expand Down Expand Up @@ -318,8 +318,8 @@ final protected function createXMLContainerExport()
}
$manager = $this->export_handler->manager()->handler();
if (count($ref_ids_all) === 1) {
$export_info = $manager->getExportInfo(
$this->data_factory->objId($this->obj->getId()),
$export_info = $manager->getExportInfoWithObject(
$this->obj,
time()
);
$element = $manager->createExport(
Expand Down

0 comments on commit e63f595

Please sign in to comment.