ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
class.ilFileImporter.php
Go to the documentation of this file.
1 <?php
2 
27 {
28  protected ?ilObjFile $current_obj = null;
29 
34  public function importXmlRepresentation(
35  string $a_entity,
36  string $a_id,
37  string $a_xml,
38  ilImportMapping $a_mapping
39  ): void {
40  // case i container
41  if ($new_id = $a_mapping->getMapping('components/ILIAS/Container', 'objs', $a_id)) {
42  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
43  $newObj->setVersion(
44  0
45  ); // If $version is 0 from database, it will be set to 1 in ilObFile::doRead(). In ilFileXMLParser::handlerBeginTag $version will being increased. So its incorrectly 2. Set $version to 0 like case ii, non container
46  } else { // case ii, non container
47  $newObj = new ilObjFile();
48  $newObj->setNoMetaDataCreation(true); // #16545
49  $newObj->create(true);
50  }
51 
52  $parser = new ilFileXMLParser($newObj, $a_xml);
53  $parser->setImportDirectory($this->getImportDirectory());
54  $parser->startParsing();
55 
56  $newObj->createProperties();
57 
58  $parser->setFileContents();
59  $this->current_obj = $newObj;
60 
61  $newObj->update(); // this is necessary for case ii (e.g. wiki import)
62 
63  $a_mapping->addMapping("components/ILIAS/File", "file", $a_id, $newObj->getId());
64  $a_mapping->addMapping(
65  "components/ILIAS/MetaData",
66  "md",
67  $a_id . ":0:file",
68  $newObj->getId() . ":0:file"
69  );
70  }
71 }
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
Import XML.
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getMapping(string $a_comp, string $a_entity, string $a_old_id)
Class ilObjFile.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Xml importer class.