Revision 17
Added by Manuela about 7 years ago
CoreAutoloader.php | ||
---|---|---|
48 | 48 |
private static $aReplacements = []; |
49 | 49 |
|
50 | 50 |
private static $aTransNs = [ |
51 |
// packet translations |
|
52 | 51 |
'vendor/jscalendar' => 'include/jscalendar', |
52 |
'vendor' => 'include', |
|
53 | 53 |
'bin/interfaces' => 'framework', |
54 |
// global translations
|
|
54 |
'bin/db' => 'framework/db',
|
|
55 | 55 |
'bin' => 'framework', |
56 | 56 |
'addon' => 'modules', |
57 | 57 |
'acp' => 'admin', |
58 |
'vendor' => 'include', |
|
59 | 58 |
]; |
59 |
/** |
|
60 |
* add new Namespace->Directory relation or overwrite existing |
|
61 |
* @param string $sNamespace |
|
62 |
* @param string $sDirectory |
|
63 |
*/ |
|
64 |
public static function addNamespace($sNamespace, $sDirectory) |
|
65 |
{ |
|
66 |
$sNamespace = \trim(\str_replace('\\', '/', $sNamespace), '/'); |
|
67 |
$sDirectory = \trim(\str_replace('\\', '/', $sDirectory), '/'); |
|
68 |
self::$aTransNs[$sNamespace] = $sDirectory; |
|
69 |
\krsort(self::$aTransNs); |
|
70 |
self::$aPatterns = self::$aReplacements = []; |
|
71 |
foreach (self::$aTransNs as $sPattern => $sReplacement) { |
|
72 |
self::$aPatterns[] = '@^('.$sPattern.'/)@su'; |
|
73 |
self::$aReplacements[] = $sReplacement.'/'; |
|
74 |
} |
|
75 |
} |
|
60 | 76 |
|
61 | 77 |
public static function autoLoad($sClassName) |
62 | 78 |
{ |
... | ... | |
98 | 114 |
self::$aTransNs[$sKey] = $sValue; |
99 | 115 |
} |
100 | 116 |
} |
117 |
\krsort(self::$aTransNs); |
|
101 | 118 |
self::$sInstallPath = \rtrim(\str_replace('\\', '/', \dirname(__DIR__)), '/').'/'; |
102 | 119 |
foreach (self::$aTransNs as $sPattern => $sReplacement) { |
103 | 120 |
self::$aPatterns[] = '@^('.$sPattern.'/)@su'; |
Also available in: Unified diff
added new method addNamespace()