mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Restructuring the CakeRequest::is() code and related code a little.
This commit is contained in:
parent
24c4cab4f3
commit
17e5d41e55
1 changed files with 9 additions and 17 deletions
|
@ -500,20 +500,14 @@ class CakeRequest implements ArrayAccess {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$detect = $this->_detectors[$type];
|
$detect = $this->_detectors[$type];
|
||||||
if (isset($detect['env'])) {
|
if (isset($detect['env']) && $this->_environmentDetector($detect)) {
|
||||||
if ($this->_environmentDetector($detect)) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isset($detect['header'])) {
|
if (isset($detect['header']) && $this->_environmentDetector($detect)) {
|
||||||
if ($this->_environmentDetector($detect)) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isset($detect['param'])) {
|
if (isset($detect['param']) && $this->_paramDetector($detect)) {
|
||||||
if ($this->_paramDetector($detect)) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isset($detect['callback']) && is_callable($detect['callback'])) {
|
if (isset($detect['callback']) && is_callable($detect['callback'])) {
|
||||||
return call_user_func($detect['callback'], $this);
|
return call_user_func($detect['callback'], $this);
|
||||||
|
@ -528,13 +522,11 @@ class CakeRequest implements ArrayAccess {
|
||||||
*/
|
*/
|
||||||
public function getAcceptHeaders() {
|
public function getAcceptHeaders() {
|
||||||
$headers = array();
|
$headers = array();
|
||||||
if (function_exists('getallheaders')) {
|
if (isset($_SERVER['HTTP_ACCEPT'])) {
|
||||||
|
$headers = explode(',', $_SERVER['HTTP_ACCEPT']);
|
||||||
|
} elseif (function_exists('getallheaders')) {
|
||||||
$headers = getallheaders();
|
$headers = getallheaders();
|
||||||
$headers = explode(',', $headers['Accept']);
|
$headers = explode(',', $headers['Accept']);
|
||||||
} else {
|
|
||||||
if (isset($_SERVER['HTTP_ACCEPT'])) {
|
|
||||||
$headers = explode(',', $_SERVER['HTTP_ACCEPT']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $headers;
|
return $headers;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue