Root.php
1.83 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
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
<?php
/**
* Created by PhpStorm.
* User: Zip
* Date: 14/12/7
* Time: 上午12:45
*/
namespace Hood\Core;
use Hood\Core\Server;
class Root
{
/**
* 应用环境
* @var string
*/
protected $applicationEnv;
/**
* 缓存时间
* @var int
*/
protected $_cacheExpire = 3600;
/**
* 缓存
* @var bool
*/
protected $_cacheStatus = true;
/**
* 缓存key
* @var null
*/
protected $_cacheKey = null;
/**
* 缓存tagName
* @var string
*/
protected $_cacheTagName = '';
public function __construct()
{
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer');
defined('APPLICATION_SYSTEM_CONFIG') || define('APPLICATION_SYSTEM_CONFIG', '/Data/Code/SystemConfig');
}
/**
* 获取应用环境
* @return string
*/
public function getApplicationEnv()
{
return $this->applicationEnv;
}
/**
* 设置应用环境
* @param $env
* @return $this
*/
public function setApplicationEnv($env)
{
define('APPLICATION_ENV', $env);
return $this;
}
/**
*
* @param $configFile
* @return $this
*/
public function setApplicationSystemConfig($configFile)
{
define('APPLICATION_SYSTEM_CONFIG', $configFile);
return $this;
}
/**
* 获取server
* @param $serviceName
* @param string $suffix
* @return Server
*/
public function getServerHost($serviceName, $suffix = 'config.ini')
{
$serviceFileArray = array(
$serviceName,
APPLICATION_ENV,
$suffix
);
$serviceFile = APPLICATION_SYSTEM_CONFIG . DIRECTORY_SEPARATOR . implode('.', $serviceFileArray);
return new Server($serviceFile);
}
}