ILIAS  release_8 Revision v8.24
class.ilGroupImporter.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
5
16{
17 private ?ilObjGroup $group = null;
18
19 public function __construct()
20 {
21 }
22
23 public function init(): void
24 {
25 }
26
30 public function importXmlRepresentation(
31 string $a_entity,
32 string $a_id,
33 string $a_xml,
34 ilImportMapping $a_mapping
35 ): void {
36 if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
37 $refs = ilObject::_getAllReferences((int) $new_id);
38 $ref_id = end($refs);
39 $this->group = ilObjectFactory::getInstanceByRefId((int) $ref_id, false);
40 } elseif ($new_id = $a_mapping->getMapping('Services/Container', 'refs', "0")) {
41 $this->group = ilObjectFactory::getInstanceByRefId((int) $new_id, false);
42 } elseif (!$this->group instanceof ilObjGroup) {
43 $this->group = new ilObjGroup();
44 $this->group->create();
45 }
46 try {
47 $parser = new ilGroupXMLParser($this->group, $a_xml, 0);
48 $parser->setMode(ilGroupXMLParser::$UPDATE);
49
50 // avoid duplicate MD sets
51 $this->group->deleteMetaData();
52
53 $parser->startParsing();
54 $a_mapping->addMapping('Modules/Group', 'grp', $a_id, (string) $this->group->getId());
56 $GLOBALS['DIC']->logger()->grp()->warning('Parsing failed with message, "' . $e->getMessage() . '".');
57 }
58 }
59}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
folder xml importer
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
@inheritDoc
Group Import Parser.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
SaxParserException thrown by ilSaxParser if property throwException is set.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
$ref_id
Definition: ltiauth.php:67