mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
修正Request类cookie方法
This commit is contained in:
@@ -807,9 +807,21 @@ class Request
|
|||||||
if (is_array($name)) {
|
if (is_array($name)) {
|
||||||
return $this->cookie = array_merge($this->cookie, $name);
|
return $this->cookie = array_merge($this->cookie, $name);
|
||||||
} elseif (!empty($name)) {
|
} elseif (!empty($name)) {
|
||||||
$name = Cookie::prefix() . $name;
|
$data = Cookie::has($name) ? Cookie::get($name) : $default;
|
||||||
|
} else {
|
||||||
|
$data = $this->cookie;
|
||||||
}
|
}
|
||||||
return $this->input($this->cookie, $name, $default, $filter);
|
|
||||||
|
// 解析过滤器
|
||||||
|
$filter = $this->getFilter($filter, $default);
|
||||||
|
|
||||||
|
if (is_array($data)) {
|
||||||
|
array_walk_recursive($data, [$this, 'filterValue'], $filter);
|
||||||
|
reset($data);
|
||||||
|
} else {
|
||||||
|
$this->filterValue($data, $name, $filter);
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -986,18 +998,8 @@ class Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 解析过滤器
|
// 解析过滤器
|
||||||
if (is_null($filter)) {
|
$filter = $this->getFilter($filter, $default);
|
||||||
$filter = [];
|
|
||||||
} else {
|
|
||||||
$filter = $filter ?: $this->filter;
|
|
||||||
if (is_string($filter)) {
|
|
||||||
$filter = explode(',', $filter);
|
|
||||||
} else {
|
|
||||||
$filter = (array) $filter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$filter[] = $default;
|
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
array_walk_recursive($data, [$this, 'filterValue'], $filter);
|
array_walk_recursive($data, [$this, 'filterValue'], $filter);
|
||||||
reset($data);
|
reset($data);
|
||||||
@@ -1026,6 +1028,23 @@ class Request
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getFilter($filter, $default)
|
||||||
|
{
|
||||||
|
if (is_null($filter)) {
|
||||||
|
$filter = [];
|
||||||
|
} else {
|
||||||
|
$filter = $filter ?: $this->filter;
|
||||||
|
if (is_string($filter)) {
|
||||||
|
$filter = explode(',', $filter);
|
||||||
|
} else {
|
||||||
|
$filter = (array) $filter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$filter[] = $default;
|
||||||
|
return $filter;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 递归过滤给定的值
|
* 递归过滤给定的值
|
||||||
* @param mixed $value 键值
|
* @param mixed $value 键值
|
||||||
|
|||||||
Reference in New Issue
Block a user