2016-09-27 06:20:02 +00:00
|
|
|
<?php
|
|
|
|
|
2018-05-23 09:08:11 +00:00
|
|
|
$vnAutoloadReplace = function($matches) {
|
|
|
|
$match = strtolower($matches[0]);
|
2016-09-27 06:20:02 +00:00
|
|
|
|
2018-05-23 09:08:11 +00:00
|
|
|
if (strlen($match) == 1)
|
2016-09-27 06:20:02 +00:00
|
|
|
return $match;
|
2022-07-07 09:15:53 +00:00
|
|
|
if ($match[0] == '\\')
|
|
|
|
return '/'. $match[1];
|
2016-09-27 06:20:02 +00:00
|
|
|
|
2022-07-07 09:15:53 +00:00
|
|
|
return $match[0] .'-'. $match[1];
|
2016-09-27 06:20:02 +00:00
|
|
|
};
|
|
|
|
|
2018-05-23 09:08:11 +00:00
|
|
|
spl_autoload_register(function($className) {
|
2016-09-27 06:20:02 +00:00
|
|
|
global $vnAutoloadReplace, $vnAutoloadMap;
|
|
|
|
|
2018-05-23 09:08:11 +00:00
|
|
|
$classPath = preg_replace_callback('/.?[A-Z]/', $vnAutoloadReplace, $className);
|
2016-09-27 06:20:02 +00:00
|
|
|
$classPath .= '.php';
|
|
|
|
|
2018-05-23 09:08:11 +00:00
|
|
|
if (isset($vnAutoloadMap))
|
2018-06-06 11:11:06 +00:00
|
|
|
foreach ($vnAutoloadMap as $prefix => $location) {
|
2018-05-23 09:08:11 +00:00
|
|
|
$prefixLen = strlen($prefix);
|
2016-09-27 06:20:02 +00:00
|
|
|
|
2018-05-23 09:08:11 +00:00
|
|
|
if (strncmp($classPath, $prefix, $prefixLen) == 0) {
|
|
|
|
$classPath = "$location/". substr($classPath, $prefixLen);
|
2016-09-27 06:20:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-07 09:15:53 +00:00
|
|
|
if ($classPath[0] != '/')
|
2018-05-23 09:08:11 +00:00
|
|
|
$classPath = stream_resolve_include_path($classPath);
|
2016-09-27 06:20:02 +00:00
|
|
|
|
2018-05-23 09:08:11 +00:00
|
|
|
if (file_exists($classPath))
|
2016-09-27 06:20:02 +00:00
|
|
|
require_once $classPath;
|
|
|
|
});
|