/**
* 从请求中获取值,包含POST和GET请求域以及通过php://input获取的数据
* @param $key
* @param string $value
* @return string
*/
protected function get($key, $value = '')
{
$params = ArrayHelper::merge($_GET, $_POST);
if (isset($params[$key])) {
return $params[$key];
}
foreach ($this->request->getBodyParams() as $k => $val) {
if (!isset($params[$k])) {
$params[$k] = $val;
}
}
if (isset($params[$key])) {
return $params[$key];
}
if ($this->request->getCookies()->has($key)) {
return $this->request->getCookies()->getValue($key);
}
return $value;
}