ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilXmlExporter.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
27 abstract class ilXmlExporter
28 {
29  protected string $dir_relative = "";
30  protected string $dir_absolute = "";
31  protected ilExport $exp;
32 
33  public function __construct()
34  {
35  }
36 
37  public function setExport(ilExport $a_exp): void
38  {
39  $this->exp = $a_exp;
40  }
41 
42  public function getExport(): ilExport
43  {
44  return $this->exp;
45  }
46 
47  public static function lookupExportDirectory(
48  string $a_obj_type,
49  int $a_obj_id,
50  string $a_export_type = 'xml',
51  string $a_entity = ""
52  ): string {
53  $ent = ($a_entity == "")
54  ? ""
55  : "_" . $a_entity;
56 
57  if ($a_export_type == 'xml') {
58  return ilFileUtils::getDataDir() . "/" . $a_obj_type . $ent . "_data" . "/" . $a_obj_type . "_" . $a_obj_id . "/export";
59  }
60  return ilFileUtils::getDataDir() . "/" . $a_obj_type . $ent . "_data" . "/" . $a_obj_type . "_" . $a_obj_id . "/export_" . $a_export_type;
61  }
62 
63  abstract public function getXmlRepresentation(
64  string $a_entity,
65  string $a_schema_version,
66  string $a_id
67  ): string;
68 
69  abstract public function init(): void;
70 
71  public function setExportDirectories(string $a_dir_relative, string $a_dir_absolute): void
72  {
73  $this->dir_relative = $a_dir_relative;
74  $this->dir_absolute = $a_dir_absolute;
75  }
76 
77  public function getRelativeExportDirectory(): string
78  {
79  return $this->dir_relative;
80  }
81 
82  public function getAbsoluteExportDirectory(): string
83  {
84  return $this->dir_absolute;
85  }
86 
92  string $a_entity,
93  string $a_target_release,
94  array $a_ids
95  ): array {
96  return [];
97  }
98 
104  string $a_entity,
105  string $a_target_release,
106  array $a_ids
107  ): array {
108  return array();
109  }
110 
123  abstract public function getValidSchemaVersions(string $a_entity): array;
124 
125  final public function determineSchemaVersion(
126  string $a_entity,
127  string $a_target_release
128  ): array {
129  $svs = $this->getValidSchemaVersions($a_entity);
130  $found = false;
131  $rsv = [];
132  foreach ($svs as $k => $sv) {
133  if (!$found) {
134  if (version_compare($sv["min"], ILIAS_VERSION_NUMERIC, "<=")
135  && ($sv["max"] == "" || version_compare($sv["max"], ILIAS_VERSION_NUMERIC, ">="))) {
136  $rsv = $sv;
137  $rsv["schema_version"] = $k;
138  $found = true;
139  }
140  }
141  }
142  return $rsv;
143  }
144 }
const ILIAS_VERSION_NUMERIC
determineSchemaVersion(string $a_entity, string $a_target_release)
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...
getXmlExportHeadDependencies(string $a_entity, string $a_target_release, array $a_ids)
Get head dependencies.
setExport(ilExport $a_exp)
static lookupExportDirectory(string $a_obj_type, int $a_obj_id, string $a_export_type='xml', string $a_entity="")
setExportDirectories(string $a_dir_relative, string $a_dir_absolute)
static getDataDir()
get data directory (outside webspace)
getValidSchemaVersions(string $a_entity)
Returns schema versions that the component can export to.
getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids)
Get tail dependencies.
getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id)