ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ImportOrgUnitTree.php
Go to the documentation of this file.
1<?php
2
4
6
13{
14 const ORG_UNIT_TREE = 'OrgUnitTree';
15
16
23 protected function run(array $params) : void
24 {
25 global $DIC;
26 $DIC->language()->loadLanguageModule('orgu');
27
28 $importer = new ilOrgUnitSimpleImport();
29
30 $xml = simplexml_load_string($params['OrgUnitTree']);
31
32 if ($xml) {
33 foreach ($xml->children() as $ou_id => $node) {
34 $importer->simpleImportElement(simplexml_load_string($node->asXML()));
35 }
36 } else {
37 throw new \ilSoapPluginException("Could not Read the XML File");
38 }
39
40 if (count($importer->getErrors()) || count($importer->getWarnings())) {
41 $arr_msg = [];
42 if ($importer->hasWarnings()) {
43 $arr_msg[] = $DIC->language()->txt("import_terminated_with_warnings");
44 foreach ($importer->getWarnings() as $warning) {
45 $arr_msg[$warning["import_id"]] = $DIC->language()->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")";
46 }
47 }
48 if ($importer->hasErrors()) {
49 $arr_msg[] = $DIC->language()->txt("import_terminated_with_errors");
50 foreach ($importer->getErrors() as $error) {
51 $arr_msg[$error["import_id"]] = $DIC->language()->txt($error["lang_var"]) . " (Import ID: " . $error["import_id"] . ")";
52 }
53 }
54
55 throw new \ilSoapPluginException(implode(" / ", $arr_msg));
56 }
57 }
58
59
63 public function getName()
64 {
65 return "importOrgUnitsSimpleXML";
66 }
67
68
72 protected function getAdditionalInputParams()
73 {
74 return array(self::ORG_UNIT_TREE => Base::TYPE_STRING);
75 }
76
77
81 public function getOutputParams()
82 {
83 return [];
84 }
85
86
90 public function getDocumentation()
91 {
92 return "Imports ILIAS Organisational Units (SimpleXML)";
93 }
94}
An exception for terminatinating execution or to throw for unit testing.
getOutputParams()
Get the output parameters in the same format as the input parameters.array
getDocumentation()
Get the documentation of this method.string
Class ilOrgUnitSimpleImport.
$xml
Definition: metadata.php:332
$DIC
Definition: xapitoken.php:46