ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
XmlExporterBridge.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Export\ExportHandler\Factory as ExportHandler;
27use Psr\Log\LoggerInterface as Logger;
28
40{
41 protected readonly ExportHandler $export_handler;
43 protected readonly Exporter $exporter;
44 protected readonly Logger $logger;
45
50 private function processExport(): ExportContext
51 {
52 $context = $this->context_holder->get();
53
54 if ($context->getPhase()->value < ExportPhase::Prepare->value) {
55 $context->setLogger($this->logger);
56 $this->exporter->prepare($context);
57 }
58
59 if ($context->getPhase()->value < ExportPhase::Process->value) {
60 $context->setSerializer(XmlSerializer::inMemory());
61 $this->exporter->process($context);
62 }
63
64 $this->context_holder->set($context);
65 return $context;
66 }
67
72 private function finalizeExport(): ExportContext
73 {
74 $context = $this->processExport();
75
76 if ($context->getPhase()->value < ExportPhase::Write->value) {
77 $context->setPathInfo($this->createPathInfo());
78 $context->setWriter($this->exp->getExportWriter());
79
80 $this->exporter->write($context);
81 }
82
83 $this->context_holder->clear();
84 return $context;
85 }
86
87 private function initExportContext(
88 string $component,
89 string $target_release,
90 string $type,
91 array $object_ids,
92 string $option = ''
93 ): ExportContext {
94 $object_ids = array_slice($object_ids, 0, 1);
95 $target = $this->export_handler->target()->handler()
96 ->withType($type)
97 ->withTargetRelease($target_release)
98 ->withObjectIds($object_ids)
99 ->withClassname(static::class)
100 ->withComponent($component);
101
102 $context = $this->context_holder->create(
103 $target,
104 $this->export_handler->consumer()->exportConfig()->collection(),
105 $option
106 );
107
108 return $context;
109 }
110
111 private function createPathInfo(): ExportPath
112 {
113 return $this->export_handler->info()->export()->path()->handler()
114 ->withPathToComponentDirInContainer($this->exp->getExportDirInContainer())
115 ->withPathToComponentExpDirInContainer($this->exp->getPathToComponentExpDirInContainer())
116 ->withSetNumber($this->exp->getSetNumber())
117 ->withIsContainerExport($this->exp->isContainerExport());
118 }
119}
An Exporter is responsible for orchestrating the export process.
Definition: Exporter.php:30
finalizeExport()
Finalizes the export by setting the path info and writer and calling the write phase of the exporter.
initExportContext(string $component, string $target_release, string $type, array $object_ids, string $option='')
trait XmlExporterBridge
Trait to bridge the export functionality between the ILIAS xml export and the local exporter classes.
processExport()
Processes the export in memory using the request export context.