Config.php
1.57 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
57
<?php
namespace QSnsApi;
class Config
{
public static $production = "/service/";
public static $testing = "/service/";
public static $developer = "/service/";
/**
* ClassNameUriList ,
* 可以定义不同的方法的地址,主要是本地开发使用
* 或者使用非本站点的Service
* @var array
*/
public static $productionClassNameUri = array(
'admin.profile' => 'http://www.qin.com/service/admin/profile'
);
/**
* 测试配置列表
* @var array
*/
public static $testingClassNameUri = array();
/**
* 开发者配置列表
* @var array
*/
public static $developerClassNameUri = array(
'admin.profile' => 'http://www.yoho.com/service/admin/profile',
);
/**
* 获取URI
* @param $className
* @return string
*/
public static function getUri($className)
{
$environ = ini_get('yaf.environ');
$environClassName = $environ . 'ClassNameUri';
if (!property_exists('QApi\Config', $environClassName)) {
throw new \Exception('Environ Class Is Null.');
}
$environClassList = self::$$environClassName;
if (isset($environClassList[$className])) {
return $environClassList[$className];
}
if (!isset(self::$$environ) || !isset($_SERVER['HTTP_HOST'])) {
throw new \Exception('Service Url Is Null.');
}
$className = str_replace(array('.'), array('/'), $className);
return 'http://' . $_SERVER['HTTP_HOST'] . self::$$environ . $className;
}
}