Permalink
Browse files

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

  • Loading branch information...
burzum committed Nov 21, 2014
1 parent 24c4cab commit 17e5d41e55712fd1a1320a79f584dc3edd465905
Showing with 9 additions and 17 deletions.
  1. +9 −17 lib/Cake/Network/CakeRequest.php
@@ -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);
@@ -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;
}

0 comments on commit 17e5d41

Please sign in to comment.