Restructuring the CakeRequest::is() code and related code a little.

This commit is contained in:
Florian Krämer 2014-11-21 18:49:36 +01:00
parent 24c4cab4f3
commit 17e5d41e55

View file

@ -500,21 +500,15 @@ class CakeRequest implements ArrayAccess {
return false;
}
$detect = $this->_detectors[$type];
if (isset($detect['env'])) {
if ($this->_environmentDetector($detect)) {
if (isset($detect['env']) && $this->_environmentDetector($detect)) {
return true;
}
}
if (isset($detect['header'])) {
if ($this->_environmentDetector($detect)) {
if (isset($detect['header']) && $this->_environmentDetector($detect)) {
return true;
}
}
if (isset($detect['param'])) {
if ($this->_paramDetector($detect)) {
if (isset($detect['param']) && $this->_paramDetector($detect)) {
return true;
}
}
if (isset($detect['callback']) && is_callable($detect['callback'])) {
return call_user_func($detect['callback'], $this);
}
@ -528,13 +522,11 @@ class CakeRequest implements ArrayAccess {
*/
public function getAcceptHeaders() {
$headers = array();
if (function_exists('getallheaders')) {
$headers = getallheaders();
$headers = explode(',', $headers['Accept']);
} else {
if (isset($_SERVER['HTTP_ACCEPT'])) {
$headers = explode(',', $_SERVER['HTTP_ACCEPT']);
}
} elseif (function_exists('getallheaders')) {
$headers = getallheaders();
$headers = explode(',', $headers['Accept']);
}
return $headers;
}