-
Notifications
You must be signed in to change notification settings - Fork 162
/
autoloader.php
104 lines (98 loc) · 4.03 KB
/
autoloader.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
function autoloadRegistry($className) {
$fileName = str_replace('Metaregistrar\\EPP\\', '', $className);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$fileName = __DIR__ . '\\Registries\\' . $fileName . '\\eppConnection.php';
} else {
$fileName = __DIR__ . '/Registries/' . $fileName . '/eppConnection.php';
}
//echo "Test autoload registry epp $fileName\n";
if (is_readable($fileName)) {
//echo "Autoloaded registry epp $fileName\n";
require($fileName);
}
$fileName = str_replace('Metaregistrar\\TMCH\\', '', $className);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$fileName = __DIR__ . '\\Registries\\' . $fileName . '\\tmchConnection.php';
} else {
$fileName = __DIR__ . '/Registries/' . $fileName . '/tmchConnection.php';
}
//echo "Test autoload registry tmch $fileName\n";
if (is_readable($fileName)) {
//echo "Autoloaded registry tmch $fileName\n";
require($fileName);
}
}
function autoloadEPP($className) {
// First load data elements
$fileName = str_replace('Metaregistrar\\EPP\\', '', $className);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$fileName = __DIR__ . '\\Protocols\\EPP\\eppData\\' . $fileName . '.php';
} else {
$fileName = __DIR__ . '/Protocols/EPP/eppData/' . $fileName . '.php';
}
//echo "Test autoload data $fileName\n";
if (is_readable($fileName)) {
//echo "Autoloaded data $fileName\n";
require($fileName);
}
// Then load protocol files
$fileName = str_replace('Metaregistrar\\', '', $className);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$fileName = __DIR__ . '\\Protocols\\' . $fileName . '.php';
// Support for EPP Request file structure
if (strpos($className, 'Request')) {
$fileName = str_replace('Protocols\\EPP\\', 'Protocols\\EPP\\eppRequests\\', $fileName);
}
// Support for EPP Response file structure
if (strpos($className, 'Response')) {
$fileName = str_replace('Protocols\\EPP\\', 'Protocols\\EPP\\eppResponses\\', $fileName);
}
} else {
$fileName = __DIR__ . '/Protocols/' . str_replace('\\', '/', $fileName) . '.php';
// Support for EPP Request file structure
if (strpos($className, 'Request')) {
$fileName = str_replace('Protocols/EPP/', 'Protocols/EPP/eppRequests/', $fileName);
}
// Support for EPP Response file structure
if (strpos($className, 'Response')) {
$fileName = str_replace('Protocols/EPP/', 'Protocols/EPP/eppResponses/', $fileName);
}
}
//echo "Test autoload EPP $fileName\n";
if (is_readable($fileName)) {
//echo "Autoloaded EPP $fileName\n";
require($fileName);
}
}
function autoloadTMCH($className) {
// First load data elements
$fileName = str_replace('Metaregistrar\\TMCH\\', '', $className);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$fileName = __DIR__ . '\\Protocols\\TMCH\\tmchData\\' . $fileName . '.php';
} else {
$fileName = __DIR__ . '/Protocols/TMCH/tmchData/' . $fileName . '.php';
}
//echo "Test autoload tmch data $fileName\n";
if (is_readable($fileName)) {
// echo "Autoloaded tmch data $fileName\n";
require($fileName);
}
// Then load protocol files
$fileName = str_replace('Metaregistrar\\TMCH\\', '', $className);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$fileName = __DIR__ . '\\Protocols\\TMCH\\' . $fileName . '.php';
// Support for EPP Request file structure
} else {
$fileName = __DIR__ . '/Protocols/TMCH/' . str_replace('\\', '/', $fileName) . '.php';
// Support for EPP Request file structure
}
//echo "Test autoload TMCH $fileName\n";
if (is_readable($fileName)) {
//echo "Autoloaded TMCH $fileName\n";
require($fileName);
}
}
spl_autoload_register('autoloadEPP');
spl_autoload_register('autoloadTMCH');
spl_autoload_register('autoloadRegistry');