forked from Shadowss/TravianZ
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoloader.php
More file actions
56 lines (45 loc) · 2.32 KB
/
Copy pathautoloader.php
File metadata and controls
56 lines (45 loc) · 2.32 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename : autoloader.php ##
## Type : In Game Autoloader GameEngine ##
## --------------------------------------------------------------------------- ##
## Developed by : Dzoki ##
## Refactored by : Shadow ##
## Redesign by : Shadow ##
## --------------------------------------------------------------------------- ##
## Contact : cata7007@gmail.com ##
## Project : TravianZ ##
## URLs: : https://travianz.org ##
## GitHub : https://github.com/Shadowss/TravianZ ##
## --------------------------------------------------------------------------- ##
## License : TravianZ Project ##
## Copyright : TravianZ (c) 2010-2026. All rights reserved. ##
## --------------------------------------------------------------------------- ##
#################################################################################
function autoloadClass($class) {
$clazz = str_replace(['App\\', '\\'], ['', '/'], $class);
$class_found = false;
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
// 1. default path (actual)
$path1 = $autoprefix . 'src/' . $clazz . '.php';
// 2. fallback GameEngine (YOUR CASE)
$path2 = $autoprefix . 'GameEngine/' . $clazz . '.php';
if (file_exists($path1)) {
include_once $path1;
$class_found = true;
break;
}
if (file_exists($path2)) {
include_once $path2;
$class_found = true;
break;
}
}
if (!$class_found) {
throw new Exception('Unable to find class ' . $clazz . '.');
}
}
spl_autoload_register('autoloadClass');