ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilImportContainer.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 public function __construct(int $a_target_id)
28 {
29 parent::__construct($a_target_id);
30 }
31
32 protected function doImportObject(
33 string $dir,
34 string $a_type,
35 string $a_component = "",
36 string $a_tmpdir = ""
37 ): array {
38 $manifest_file = $dir . "/manifest.xml";
39 if (!file_exists($manifest_file)) {
40 return [];
41 }
42 $parser = new ilManifestParser($manifest_file);
43
44 // Handling single containers without subitems
45 // @todo: check if this is required
46 // all container have container export sets
47 $all_importers = array();
48 if (!$parser->getExportSets()) {
49 $this->createDummy($a_type);
50 $import_info = parent::doImportObject($dir, $a_type);
51 $all_importers = array_merge($all_importers, $import_info['importers']);
52 return $import_info;
53 }
54
55 // Handling containers with subitems
56 $first = true;
57 $ret = [];
58 foreach ($parser->getExportSets() as $set) {
59 $import_info = parent::doImportObject($dir . DIRECTORY_SEPARATOR . $set['path'], $set['type']);
60 $all_importers = array_merge($all_importers, $import_info['importers']);
61 if ($first) {
62 $ret = $import_info;
63 $first = false;
64 }
65 }
66 // after container import is finished, call all importers to perform a final processing
67 foreach ($all_importers as $importer) {
69 }
70 return $ret;
71 }
72
73 protected function createDummy(string $a_type): ilObject
74 {
75 $class_name = "ilObj" . $this->objDefinition->getClassName($a_type);
76
77 $new = new $class_name();
78 $new->setTitle('Import');
79 $new->create(true);
80 $new->createReference();
81 $new->putInTree($this->getMapping()->getTargetId());
82 $new->setPermissions($this->getMapping()->getTargetId());
83
84 $this->getMapping()->addMapping('components/ILIAS/Container', 'objs', '0', (string) $new->getId());
85 $this->getMapping()->addMapping('components/ILIAS/Container', 'refs', '0', (string) $new->getRefId());
86
87 return $new;
88 }
89}
__construct(int $a_target_id)
doImportObject(string $dir, string $a_type, string $a_component="", string $a_tmpdir="")
Import repository object export file.
Import class.
ilXmlImporter $importer
Manifest parser for ILIAS standard export files.
Class ilObject Basic functions for all objects.
afterContainerImportProcessing(ilImportMapping $mapping)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc