ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilImportExportFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 public const PLUGINS_DIR = "Plugins";
28
29 public static function getExporterClass(string $a_type): string
30 {
34 global $DIC;
35 $objDefinition = $DIC['objDefinition'];
36
37 if ($objDefinition->isPlugin($a_type)) {
38 $classname = 'il' . $objDefinition->getClassName($a_type) . 'Exporter';
39 $location = $objDefinition->getLocation($a_type);
40 if (include_once $location . '/class.' . $classname . '.php') {
41 return $classname;
42 }
43 } else {
44 $comp = $objDefinition->getComponentForType($a_type);
45 $componentParts = explode("/", $comp);
46 $class = array_pop($componentParts);
47 $class = "il" . $class . "Exporter";
48
49 // page component plugin exporter classes are already included
50 // the component is not registered by ilObjDefinition
51 if (class_exists($class)) {
52 return $class;
53 }
54
55 // the next line had a "@" in front of the include_once
56 // I removed this because it tages ages to track down errors
57 // if the include class contains parse errors.
58 // Alex, 20 Jul 2012
59 if (include_once "./" . $comp . "/classes/class." . $class . ".php") {
60 return $class;
61 }
62 }
63
64 throw new InvalidArgumentException('Invalid exporter type given');
65 }
66
67 public static function getComponentForExport(string $a_type): string
68 {
72 global $DIC;
73
74 $objDefinition = $DIC['objDefinition'];
75 if ($objDefinition->isPlugin($a_type)) {
76 return self::PLUGINS_DIR . "/" . $a_type;
77 } else {
78 return $objDefinition->getComponentForType($a_type);
79 }
80 }
81
88 public static function getImporterClass(string $a_component): string
89 {
90 # Compatibility with older exports
91 # Object changed to ILIASObject with the component revision
92 $a_component = ($a_component === "components/ILIAS/Object") ? "components/ILIAS/ILIASObject" : $a_component;
93 $a_component = ($a_component === "Services/Object") ? "components/ILIAS/ILIASObject" : $a_component;
97 global $DIC;
98 $objDefinition = $DIC['objDefinition'];
99
100 $parts = explode('/', $a_component);
101 $component_type = $parts[0];
102 $component = $parts[2] ?? $parts[1];
103 $class = '';
104 if ($component_type == self::PLUGINS_DIR &&
105 $objDefinition->isPlugin($component)) {
106 $classname = 'il' . $objDefinition->getClassName($component) . 'Importer';
107 $location = $objDefinition->getLocation($component);
108 if (include_once $location . '/class.' . $classname . '.php') {
109 return $classname;
110 }
111 } else {
112 $class = "il" . $component . "Importer";
113 // treat special case of page component plugins
114 // they are imported with component type PLUGINS_DIR
115 // but are not yet recognized by ilObjDefinition::isPlugin()
116 //
117 // if they are active, then their importer class is already included by ilCOPageImporter::init()
118 if (class_exists($class)) {
119 return $class;
120 }
121 // the page component plugin is not installed or not active
122 // return an empty class name instead of throwing an exception
123 // in this case the import should be continued without treating the page component
124 elseif ($component_type == self::PLUGINS_DIR) {
125 return "";
126 }
127
128 if (is_file("./" . $a_component . "/classes/class." . $class . ".php")) {
129 return $class;
130 }
131 }
132
133 throw new InvalidArgumentException('Invalid importer type given: ' . "./" . $a_component . "/classes/class." . $class . ".php");
134 }
135}
$location
Definition: buildRTE.php:22
Factory for importer/exporter implementers.
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
global $DIC
Definition: shib_login.php:26