ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilGroupImporter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
30{
31 private ?ilObjGroup $group = null;
32
33 public function __construct()
34 {
35 }
36
37 public function init(): void
38 {
39 }
40
44 public function importXmlRepresentation(
45 string $a_entity,
46 string $a_id,
47 string $a_xml,
48 ilImportMapping $a_mapping
49 ): void {
50 if ($new_id = $a_mapping->getMapping('components/ILIAS/Container', 'objs', $a_id)) {
51 $refs = ilObject::_getAllReferences((int) $new_id);
52 $ref_id = end($refs);
53 $this->group = ilObjectFactory::getInstanceByRefId((int) $ref_id, false);
54 } elseif ($new_id = $a_mapping->getMapping('components/ILIAS/Container', 'refs', "0")) {
55 $this->group = ilObjectFactory::getInstanceByRefId((int) $new_id, false);
56 } elseif (!$this->group instanceof ilObjGroup) {
57 $this->group = new ilObjGroup();
58 $this->group->create();
59 }
60 try {
61 $parser = new ilGroupXMLParser($this->group, $a_xml, 0);
62 $parser->setMode(ilGroupXMLParser::$UPDATE);
63
64 // avoid duplicate MD sets
65 $this->group->deleteMetaData();
66
67 $parser->startParsing();
68 $a_mapping->addMapping('components/ILIAS/Group', 'grp', $a_id, (string) $this->group->getId());
69 $a_mapping->addMapping(
70 'components/ILIAS/MetaData',
71 'md',
72 $a_id . ':0:grp',
73 $this->group->getId() . ':0:grp'
74 );
75
77 $GLOBALS['DIC']->logger()->grp()->warning('Parsing failed with message, "' . $e->getMessage() . '".');
78 }
79 }
80}
folder xml importer
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
@inheritDoc
Group Import Parser.
Class ilObjGroup.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Xml importer class.
$ref_id
Definition: ltiauth.php:66
if(!file_exists('../ilias.ini.php'))
$GLOBALS["DIC"]
Definition: wac.php:54