Skip to content

Commit

Permalink
Allow 'options' to be given as array when adding a param detector - s…
Browse files Browse the repository at this point in the history
…imilar to env / options.

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

    array('param'=>'{param-name}', 'options'=>array())
  • Loading branch information
clns committed Aug 27, 2013
1 parent 499212a commit cf3dfb0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/Cake/Network/CakeRequest.php
Expand Up @@ -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);
Expand Down

0 comments on commit cf3dfb0

Please sign in to comment.