Root.php
2.54 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
/**
* Created by PhpStorm.
* User: Zip
* Date: 14/12/7
* Time: 上午12:45
*/
namespace Hood\Core;
use Hood\Core\Server;
class Root
{
/**
* server file
* @var String
*/
protected $serviceFile;
/**
* 应用环境
* @var string
*/
protected $applicationEnv;
/**
* 缓存时间
* @var int
*/
protected $_cacheExpire = 3600;
/**
* 缓存
* @var bool
*/
protected $_cacheStatus = false;
/**
* reset默认缓存是否开启
* @var bool
*/
protected $_defaultCacheStatus = false;
/**
* 缓存key
* @var null
*/
protected $_cacheKey = null;
/**
* 缓存tagName
* @var string
*/
protected $_cacheTagName = '';
/**
* 删除多个缓存tag
*/
protected $_delTags = array();
/**
* 强制使用从
* @var bool
*/
protected $_slave = false;
/**
* 强制使用主
* @var bool
*/
protected $_master = false;
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
);
$this->serviceFile = $serviceFile = APPLICATION_SYSTEM_CONFIG . DIRECTORY_SEPARATOR . implode('.', $serviceFileArray);
$server = new Server();
$server->setFileName($serviceFile);
return $server;
}
public function master()
{
$this->_master = true;
return $this;
}
public function slave()
{
$this->_slave = true;
return $this;
}
}