ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilLearningSequenceExporter.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  protected ilSetting $settings;
24 
25  public function init(): void
26  {
27  global $DIC;
28  $this->settings = $DIC["ilSetting"];
29  }
30 
31  public function getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id): string
32  {
33  $writer = $this->getWriter((int) $a_id);
34  $writer->start();
35 
36  return $writer->getXml();
37  }
38 
39  protected function getWriter(int $obj_id): ilLearningSequenceXMLWriter
40  {
41  if ($type = ilObject::_lookupType($obj_id) != "lso") {
42  throw new Exception("Wrong type " . $type . " for lso export.");
43  }
44 
45  $ref_ids = ilObject::_getAllReferences($obj_id);
46  $ls_ref_id = end($ref_ids);
47 
49  $ls_object = ilObjectFactory::getInstanceByRefId($ls_ref_id, false);
50  if (!$ls_object) {
51  throw new Exception("Object for ref id " . $ls_ref_id . " not found.");
52  }
53 
54  $lp_settings = new ilLPObjSettings($obj_id);
55 
56  return new ilLearningSequenceXMLWriter(
57  $ls_object,
58  $this->settings,
59  $lp_settings
60  );
61  }
62 
63  public function getValidSchemaVersions(string $a_entity): array
64  {
65  return [
66  "9.0.0" => [
67  "namespace" => "http://www.ilias.de/Modules/LearningSequence/lso/9_0",
68  "xsd_file" => "ilias_lso_9_0.xsd",
69  "uses_dataset" => false,
70  "min" => "9.0",
71  "max" => ""
72  ]
73  ];
74  }
75 
76  public function getXmlExportHeadDependencies(string $a_entity, string $a_target_release, array $a_ids): array
77  {
78  return [
79  [
80  'component' => 'components/ILIAS/Container',
81  'entity' => 'struct',
82  'ids' => $a_ids
83  ]
84  ];
85  }
86 
90  public function getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids): array
91  {
92  $res = [];
93  if ($a_entity == "lso") {
94  // service settings
95  $res[] = [
96  "component" => "components/ILIAS/ILIASObject",
97  "entity" => "common",
98  "ids" => $a_ids
99  ];
100  }
101 
102  // container pages
103  foreach ($a_ids as $id) {
104  if (ilContainerPage::_exists(LSOPageType::INTRO->value, (int) $id)) {
105  $res[] = [
106  "component" => "components/ILIAS/COPage",
107  "entity" => "pg",
108  "ids" => [LSOPageType::INTRO->value . ":" . $id]
109  ];
110  }
111 
112  if (ilContainerPage::_exists(LSOPageType::EXTRO->value, (int) $id)) {
113  $res[] = [
114  "component" => "components/ILIAS/COPage",
115  "entity" => "pg",
116  "ids" => [LSOPageType::EXTRO->value . ":" . $id]
117  ];
118  }
119  }
120 
121  return $res;
122  }
123 }
$res
Definition: ltiservices.php:66
static _getAllReferences(int $id)
get all reference ids for object ID
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
global $DIC
Definition: shib_login.php:22
getXmlExportHeadDependencies(string $a_entity, string $a_target_release, array $a_ids)
getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids)
static _lookupType(int $id, bool $reference=false)