-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathautoload.php
More file actions
52 lines (49 loc) · 2.22 KB
/
autoload.php
File metadata and controls
52 lines (49 loc) · 2.22 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
<?php
class MdsColliveryAutoLoader
{
/**
* @var array
*/
protected static $classMap = [
'MdsCollivery' => '\MdsSupportingClasses\Collivery',
'EnvironmentInformationBag' => '\MdsSupportingClasses\EnvironmentInformationBag',
'GitHubPluginUpdater' => '\MdsSupportingClasses\GitHubPluginUpdater',
'MdsCache' => '\MdsSupportingClasses\MdsCache',
'MdsCheckoutFields' => '\MdsSupportingClasses\MdsCheckoutFields',
'MdsColliveryService' => '\MdsSupportingClasses\MdsColliveryService',
'MdsLogger' => '\MdsSupportingClasses\MdsLogger',
'Money' => '\MdsSupportingClasses\Money',
'ParseDown' => '\MdsSupportingClasses\ParseDown',
'UnitConverter' => '\MdsSupportingClasses\UnitConverter',
'View' => '\MdsSupportingClasses\View',
'ExceptionMiddleware' => '\MdsExceptions\ExceptionMiddleware',
'InvalidAddressDataException' => '\MdsExceptions\InvalidAddressDataException',
'InvalidCartPackageException' => '\MdsExceptions\InvalidCartPackageException',
'InvalidColliveryDataException' => '\MdsExceptions\InvalidColliveryDataException',
'InvalidResourceDataException' => '\MdsExceptions\InvalidResourceDataException',
'InvalidServiceException' => '\MdsExceptions\InvalidServiceException',
'OrderAlreadyProcessedException' => '\MdsExceptions\OrderAlreadyProcessedException',
'ProductOutOfStockException' => '\MdsExceptions\ProductOutOfStockException',
];
/**
* @param $class
*/
public static function autoload($class)
{
$classParts = explode('\\', $class);
$vendor = array_shift($classParts);
if ($vendor === 'MdsSupportingClasses' || $vendor === 'MdsExceptions') {
if (file_exists(_MDS_DIR_.'/'.$vendor.'/'.implode('/', $classParts).'.php')) {
if (!class_exists($vendor.'\\'.implode('/', $classParts))) {
require _MDS_DIR_.'/'.$vendor.'/'.implode('/', $classParts).'.php';
}
}
} elseif (array_key_exists($class, self::$classMap)) {
class_alias(self::$classMap[$class], $class);
}
}
}
spl_autoload_register(
'MdsColliveryAutoLoader::autoload',
true
);