-
Notifications
You must be signed in to change notification settings - Fork 1
/
classmap.php
35 lines (32 loc) · 1.32 KB
/
classmap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
/**
* Created by PhpStorm.
* User: 713uk13m <dev@nguyenanhung.com>
* Date: 9/19/18
* Time: 13:37
*/
spl_autoload_register(function ($className) {
$className = ltrim($className, '\\');
$fileName = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName = __DIR__ . DIRECTORY_SEPARATOR . $fileName . $className . '.php';
//
if (strpos($fileName, 'nguyenanhung\CodeIgniter\HMVC\Interfaces') !== FALSE) {
$fileName = str_replace('nguyenanhung\CodeIgniter\HMVC\Interfaces', 'src\Interfaces', $fileName);
} elseif (strpos($fileName, 'nguyenanhung\CodeIgniter\HMVC\Hmvc') !== FALSE) {
$fileName = str_replace('nguyenanhung\CodeIgniter\HMVC\Hmvc', 'src\Hmvc', $fileName);
} elseif (strpos($fileName, 'nguyenanhung\CodeIgniter\HMVC\Repository') !== FALSE) {
$fileName = str_replace('nguyenanhung\CodeIgniter\HMVC\Repository', 'src\Repository', $fileName);
} else {
$fileName = str_replace('nguyenanhung\CodeIgniter\HMVC', 'src', $fileName);
}
if (file_exists($fileName)) {
require $fileName;
return TRUE;
}
return FALSE;
});