20 |
20 |
/**
|
21 |
21 |
* Description of Autoloader
|
22 |
22 |
*
|
23 |
|
* @package Installer
|
|
23 |
* @package Core
|
24 |
24 |
* @copyright Manuela v.d.Decken <manuela@isteam.de>
|
25 |
25 |
* @author Manuela v.d.Decken <manuela@isteam.de>
|
26 |
26 |
* @license GNU General Public License 3.0
|
... | ... | |
54 |
54 |
{
|
55 |
55 |
$aMatches = \preg_split('=[\\\\/]=', $sClassName, null, \PREG_SPLIT_NO_EMPTY);
|
56 |
56 |
// insert default NS if no one is given
|
57 |
|
if (sizeof($aMatches) == 1) { array_unshift($aMatches, 'framework'); }
|
|
57 |
if (\sizeof($aMatches) == 1) { \array_unshift($aMatches, 'framework'); }
|
58 |
58 |
// translate namespaces into real dir entries
|
59 |
|
$aMatches[0] = str_replace(array_keys(self::$aTransNs), self::$aTransNs, $aMatches[0]);
|
|
59 |
$aMatches[0] = \str_replace(\array_keys(self::$aTransNs), self::$aTransNs, $aMatches[0]);
|
60 |
60 |
// first seek in namespace
|
61 |
61 |
$sFilePath = self::$sInstallPath.\implode('/', $aMatches).'.php';
|
62 |
|
if (is_readable($sFilePath)) {
|
|
62 |
if (\is_readable($sFilePath)) {
|
63 |
63 |
include $sFilePath;
|
64 |
64 |
} else {
|
65 |
65 |
// second seek in namespace with file prefix 'class.'
|
66 |
|
$sTmp = array_pop($aMatches);
|
|
66 |
$sTmp = \array_pop($aMatches);
|
67 |
67 |
$sFilePath = self::$sInstallPath.\implode('/', $aMatches).'/class.'.$sTmp.'.php';
|
68 |
|
array_push($aMatches, $sTmp);
|
69 |
|
if (is_readable($sFilePath)) {
|
|
68 |
\array_push($aMatches, $sTmp);
|
|
69 |
if (\is_readable($sFilePath)) {
|
70 |
70 |
include $sFilePath;
|
71 |
71 |
}
|
72 |
72 |
}
|
73 |
73 |
}
|
74 |
74 |
/**
|
75 |
|
* register his autoloader
|
|
75 |
* register this autoloader
|
76 |
76 |
*/
|
77 |
77 |
public static function doRegister()
|
78 |
78 |
{
|
79 |
|
self::$sInstallPath = rtrim(str_replace('\\', '/', dirname(__DIR__)), '/').'/';
|
|
79 |
self::$sInstallPath = \rtrim(\str_replace('\\', '/', \dirname(__DIR__)), '/').'/';
|
80 |
80 |
\spl_autoload_register([self, 'autoLoad']);
|
81 |
81 |
}
|
82 |
82 |
|
83 |
83 |
/**
|
84 |
|
* unregister his autoloader
|
|
84 |
* unregister this autoloader
|
85 |
85 |
*/
|
86 |
86 |
public static function unRegister()
|
87 |
87 |
{
|
added missing root / ns