forked from aliyun/aliyun-log-php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLog_Autoload.php
32 lines (29 loc) · 1.02 KB
/
Log_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
<?php
/**
* Copyright (C) Alibaba Cloud Computing
* All rights reserved
*/
$version = '0.6.0';
function Aliyun_Log_PHP_Client_Autoload($className) {
$classPath = explode('_', $className);
if ($classPath[0] == 'Aliyun') {
if(count($classPath)>5)
$classPath = array_slice($classPath, 0, 5);
if(strpos($className, 'Request') !== false){
$lastPath = end($classPath);
array_pop($classPath);
array_push($classPath,'Request');
array_push($classPath, $lastPath);
}
if(strpos($className, 'Response') !== false){
$lastPath = end($classPath);
array_pop($classPath);
array_push($classPath,'Response');
array_push($classPath, $lastPath);
}
$filePath = dirname(__FILE__) . '/' . implode('/', $classPath) . '.php';
if (file_exists($filePath))
require_once($filePath);
}
}
spl_autoload_register('Aliyun_Log_PHP_Client_Autoload');