Skip to content

Commit

Permalink
Restructuring the CakeRequest::is() code and related code a little.
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Krämer committed Nov 21, 2014
1 parent 24c4cab commit 17e5d41
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions lib/Cake/Network/CakeRequest.php
Expand Up @@ -500,20 +500,14 @@ public function is($type) {
return false;
}
$detect = $this->_detectors[$type];
if (isset($detect['env'])) {
if ($this->_environmentDetector($detect)) {
return true;
}
if (isset($detect['env']) && $this->_environmentDetector($detect)) {
return true;
}
if (isset($detect['header'])) {
if ($this->_environmentDetector($detect)) {
return true;
}
if (isset($detect['header']) && $this->_environmentDetector($detect)) {
return true;
}
if (isset($detect['param'])) {
if ($this->_paramDetector($detect)) {
return true;
}
if (isset($detect['param']) && $this->_paramDetector($detect)) {
return true;
}
if (isset($detect['callback']) && is_callable($detect['callback'])) {
return call_user_func($detect['callback'], $this);
Expand All @@ -528,13 +522,11 @@ public function is($type) {
*/
public function getAcceptHeaders() {
$headers = array();
if (function_exists('getallheaders')) {
if (isset($_SERVER['HTTP_ACCEPT'])) {
$headers = explode(',', $_SERVER['HTTP_ACCEPT']);
} elseif (function_exists('getallheaders')) {
$headers = getallheaders();
$headers = explode(',', $headers['Accept']);
} else {
if (isset($_SERVER['HTTP_ACCEPT'])) {
$headers = explode(',', $_SERVER['HTTP_ACCEPT']);
}
}
return $headers;
}
Expand Down

0 comments on commit 17e5d41

Please sign in to comment.