-
Notifications
You must be signed in to change notification settings - Fork 1
/
autoloader.php
executable file
·64 lines (59 loc) · 2.43 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
<?php
date_default_timezone_set('UTC');
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);
}
}
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);
}
}
spl_autoload_register('autoloadEPP');
spl_autoload_register('autoloadRegistry');