ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
_autoload_modules.php
Go to the documentation of this file.
1 <?php
2 
20 function temporaryLoader($class)
21 {
22  // handle the upgrade to the latest version of XMLSecLibs using namespaces
23  if (strstr($class, 'XMLSec')) {
24  if (class_exists('\\RobRichards\\XMLSecLibs\\'.$class, true)) {
25  class_alias('\\RobRichards\\XMLSecLibs\\'.$class, $class);
26  return;
27  }
28  }
29 
30  if (!strstr($class, 'SimpleSAML_')) {
31  return; // not a valid class name for old classes
32  }
33  $original = $class;
34 
35  // list of classes that have been renamed or moved
36  $renamed = array(
37  'SimpleSAML_Metadata_MetaDataStorageHandlerMDX' => 'SimpleSAML_Metadata_Sources_MDQ',
38  'SimpleSAML_Logger_LoggingHandlerSyslog' => 'SimpleSAML_Logger_SyslogLoggingHandler',
39  'SimpleSAML_Logger_LoggingHandlerErrorLog' => 'SimpleSAML_Logger_ErrorLogLoggingHandler',
40  'SimpleSAML_Logger_LoggingHandlerFile' => 'SimpleSAML_Logger_FileLoggingHandler',
41  'SimpleSAML_Logger_LoggingHandler' => 'SimpleSAML_Logger_LoggingHandlerInterface',
42  'SimpleSAML_IdP_LogoutHandler' => 'SimpleSAML_IdP_LogoutHandlerInterface',
43  'SimpleSAML_IdP_LogoutIFrame' => 'SimpleSAML_IdP_IFrameLogoutHandler',
44  'SimpleSAML_IdP_LogoutTraditional' => 'SimpleSAML_IdP_TraditionalLogoutHandler',
45  );
46  if (array_key_exists($class, $renamed)) {
47  // the class has been renamed, try to load it and create an alias
48  $class = $renamed[$class];
49  }
50 
51  // try to load it from the corresponding file
52  $path = explode('_', $class);
53  $file = dirname(__FILE__).DIRECTORY_SEPARATOR.join(DIRECTORY_SEPARATOR, $path).'.php';
54  if (file_exists($file)) {
55  require_once $file;
56  }
57 
58  // it exists, so it's not yet migrated to namespaces
59  if (class_exists($class, false) || interface_exists($class, false)) {
60  return;
61  }
62 
63  // it didn't exist, try to see if it was migrated to namespaces
64  $new = join('\\', $path);
65  if (class_exists($new, false) || interface_exists($new, false)) {
66  // do not try to autoload it if it doesn't exist! It should!
67  class_alias($new, $original);
68  SimpleSAML\Logger::warning("The class or interface '$original' is now using namespaces, please use '$new'.");
69  }
70 }
71 
72 spl_autoload_register("temporaryLoader");
73 spl_autoload_register(array('SimpleSAML\Module', 'autoloadPSR0'));
74 spl_autoload_register(array('SimpleSAML\Module', 'autoloadPSR4'));
temporaryLoader($class)
This temporary autoloader allows loading classes with their old-style names (SimpleSAML_Path_Somethin...
static warning($string)
Definition: Logger.php:179
Create styles array
The data for the language used.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file