ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilForumImporter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected \ILIAS\Style\Content\DomainService $content_style_domain;
24
25 public function init(): void
26 {
27 global $DIC;
28
29 $this->content_style_domain = $DIC
30 ->contentStyle()
31 ->domain();
32 }
33
34 public function importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping): void
35 {
36 if ($new_id = $a_mapping->getMapping('components/ILIAS/Container', 'objs', $a_id)) {
37 $newObj = ilObjectFactory::getInstanceByObjId((int) $new_id, false);
38 } else {
39 $newObj = new ilObjForum();
40 $newObj->setType('frm');
41 $newObj->create();
42 }
43
45 $parser = new ilForumXMLParser($newObj, $a_xml, $a_mapping);
46 $parser->setImportDirectory($this->getImportDirectory());
47 $parser->setImportInstallId($this->getInstallId());
48 $parser->setSchemaVersion($this->getSchemaVersion());
49 $parser->startParsing();
50
51 $a_mapping->addMapping('components/ILIAS/Forum', 'frm', $a_id, (string) $newObj->getId());
52 }
53
54 public function finalProcessing(ilImportMapping $a_mapping): void
55 {
56 parent::finalProcessing($a_mapping);
57
58 $copaMap = $a_mapping->getMappingsOfEntity('components/ILIAS/COPage', 'pg');
59 foreach ($copaMap as $newCopaId) {
60 $newCopaId = (int) substr($newCopaId, strlen(self::OBJ_TYPE) + 1);
61
62 ilForumPage::_writeParentId(self::OBJ_TYPE, $newCopaId, $newCopaId);
63 }
64
65 $style_map = $a_mapping->getMappingsOfEntity('components/ILIAS/Style', 'sty');
66 foreach ($style_map as $old_style_id => $new_style_id) {
67 if (isset(ilForumXMLParser::$style_map[$old_style_id]) &&
68 is_array(ilForumXMLParser::$style_map[$old_style_id])) {
69 foreach (ilForumXMLParser::$style_map[$old_style_id] as $new_frm_id) {
70 $this->content_style_domain
71 ->styleForObjId($new_frm_id)
72 ->updateStyleId((int) $new_style_id);
73 }
74 }
75 }
76 }
77}
finalProcessing(ilImportMapping $a_mapping)
ILIAS Style Content DomainService $content_style_domain
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
getMappingsOfEntity(string $a_comp, string $a_entity)
Class ilObjForum.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static _writeParentId(string $a_parent_type, int $a_pg_id, int $a_par_id)
Xml importer class.
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
global $DIC
Definition: shib_login.php:26