-
Notifications
You must be signed in to change notification settings - Fork 4
/
autoload.php
38 lines (38 loc) · 1022 Bytes
/
autoload.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
36
37
38
<?php
function globalAutoloader($className) {
$objPath = dirname(__FILE__);
$objPaths = explode("_",$className);
$lastPart = array_pop($objPaths);
if (count($objPaths) === 0) {
array_unshift($objPaths,'classes');
array_push($objPaths,'core');
} else {
if ($lastPart === 'DAO') {
array_unshift($objPaths,'classes');
$lastPart = '';
} else if ($lastPart === 'OBJ') {
array_unshift($objPaths,'classes');
$lastPart = '';
} else if ($lastPart === 'MODEL') {
array_unshift($objPaths,'models');
$lastPart = '';
} else if (strstr($className,'_Controller_')) {
array_pop($objPaths);
$objPaths[0] = 'controllers';
} else {
array_unshift($objPaths,'classes');
}
}
if ($lastPart != '') {
array_push($objPaths,$lastPart);
}
foreach ($objPaths as $path) {
$objPath .= DIRECTORY_SEPARATOR.$path;
}
$objPath .= '.php';
if (file_exists($objPath)) {
require($objPath);
}
}
spl_autoload_register('globalAutoloader');
require(dirname(__FILE__).'/composer/vendor/autoload.php');