ILIAS  release_8 Revision v8.24
class.ilImportExportFactory.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
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 {
93 global $DIC;
94 $objDefinition = $DIC['objDefinition'];
95
96 $parts = explode('/', $a_component);
97 $component_type = $parts[0];
98 $component = $parts[1];
99 $class = '';
100 if ($component_type == self::PLUGINS_DIR &&
101 $objDefinition->isPlugin($component)) {
102 $classname = 'il' . $objDefinition->getClassName($component) . 'Importer';
103 $location = $objDefinition->getLocation($component);
104 if (include_once $location . '/class.' . $classname . '.php') {
105 return $classname;
106 }
107 } else {
108 $class = "il" . $component . "Importer";
109 // treat special case of page component plugins
110 // they are imported with component type PLUGINS_DIR
111 // but are not yet recognized by ilObjDefinition::isPlugin()
112 //
113 // if they are active, then their importer class is already included by ilCOPageImporter::init()
114 if (class_exists($class)) {
115 return $class;
116 }
117 // the page component plugin is not installed or not active
118 // return an empty class name instead of throwing an exception
119 // in this case the import should be continued without treating the page component
120 elseif ($component_type == self::PLUGINS_DIR) {
121 return "";
122 }
123
124 if (is_file("./" . $a_component . "/classes/class." . $class . ".php")) {
125 return $class;
126 }
127 }
128
129 throw new InvalidArgumentException('Invalid importer type given: ' . "./" . $a_component . "/classes/class." . $class . ".php");
130 }
131}
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: buildRTE.php:22
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64