-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathWindCommandRequest.php
More file actions
130 lines (118 loc) · 2.85 KB
/
Copy pathWindCommandRequest.php
File metadata and controls
130 lines (118 loc) · 2.85 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
<?php
/**
* 命令行request对象
*
* @author Shi Long <[email protected]>
* @copyright ©2003-2103 phpwind.com
* @license http://www.windframework.com
* @version $Id$
* @package command
*/
class WindCommandRequest implements IWindRequest {
/**
* 请求参数信息
*
* @var array
*/
private $_attribute = array();
/**
* 应答对象
*
* @var WindCommandResponse
*/
private $_response = null;
/**
* 获得用户请求的数据
*
* @param string $key 获取的参数name,默认为null将获得$_GET和$_POST两个数组的所有值
* @param mixed $defaultValue 当获取值失败的时候返回缺省值,默认值为null
* @return mixed
*/
public function getRequest($key, $defaultValue = null) {
if (isset($_SERVER[$key])) return $_SERVER[$key];
if (isset($_ENV[$key])) return $_ENV[$key];
return $defaultValue;
}
/**
* 根据名称获得服务器和执行环境信息
*
* 主要获取的依次顺序为:_attribute、$_SERVER、$_ENV
*
* @param string $name 获取数据的key值
* @param string $defaultValue 设置缺省值,当获取值失败的时候返回缺省值,默认该值为空字串
* @return string|object|array 返回获得值
*/
public function getAttribute($key, $defaultValue = '') {
if (isset($this->_attribute[$key]))
return $this->_attribute[$key];
else if (isset($_SERVER[$key]))
return $_SERVER[$key];
else if (isset($_ENV[$key]))
return $_ENV[$key];
else
return $defaultValue;
}
/**
* 设置属性数据
*
* @param string|array|object $data 需要设置的数据
* @param string $key 设置的数据保存用的key,默认为空,当数组和object类型的时候将会执行array_merge操作
* @return void
*/
public function setAttribute($data, $key = '') {
if ($key) {
$this->_attribute[$key] = $data;
return;
}
if (is_object($data)) $data = get_object_vars($data);
if (is_array($data)) $this->_attribute = array_merge($this->_attribute, $data);
}
/**
* 获得请求类型
*
* @return string
*/
public function getRequestType() {
return 'command';
}
/* (non-PHPdoc)
* @see IWindRequest::getPathInfo()
*/
public function getPathInfo() {
return '';
}
/* (non-PHPdoc)
* @see IWindRequest::getHostInfo()
*/
public function getHostInfo() {
return '';
}
/* (non-PHPdoc)
* @see IWindRequest::getServerName()
*/
public function getServerName() {
return '';
}
/* (non-PHPdoc)
* @see IWindRequest::getServerPort()
*/
public function getServerPort() {
return '';
}
/* (non-PHPdoc)
* @see IWindRequest::getResponse()
*/
public function getResponse() {
if ($this->_response === null) {
$this->_response = new WindCommandResponse();
}
return $this->_response;
}
/* (non-PHPdoc)
* @see IWindRequest::getAcceptLanguage()
*/
public function getAcceptLanguage() {
return '';
}
}
?>