Browse files

Allow 'options' to be given as array when adding a param detector - s…

…imilar to env / options.

Allow the following when adding request detectors using CakeRequest::addDetector():

    array('param'=>'{param-name}', 'options'=>array())
  • Loading branch information...
1 parent 499212a commit cf3dfb0c66a6019b7484b27f37308a15ddc52c2b @clns clns committed Aug 27, 2013
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/Cake/Network/CakeRequest.php
View
9 lib/Cake/Network/CakeRequest.php
@@ -516,8 +516,13 @@ public function is($type) {
}
if (isset($detect['param'])) {
$key = $detect['param'];
- $value = $detect['value'];
- return isset($this->params[$key]) ? $this->params[$key] == $value : false;
+ if (isset($detect['value'])) {
+ $value = $detect['value'];
+ return isset($this->params[$key]) ? $this->params[$key] == $value : false;
+ }
+ if (isset($detect['options'])) {
+ return isset($this->params[$key]) ? in_array($this->params[$key],$detect['options']) : false;
+ }
}
if (isset($detect['callback']) && is_callable($detect['callback'])) {
return call_user_func($detect['callback'], $this);

0 comments on commit cf3dfb0

Please sign in to comment.