Skip to content
Permalink
Browse files

Re-add query() getting all parameters.

Revert "Revert "Allow Request::query() to return all query strings.""

This reverts commit 6d9f2fc.

Refs #9356
  • Loading branch information...
markstory committed Aug 27, 2016
1 parent 550b034 commit f5bf4764112dd9e60f45b680f3431c39f7869a3a
Showing with 17 additions and 9 deletions.
  1. +11 −7 src/Network/Request.php
  2. +6 −2 tests/TestCase/Network/RequestTest.php
@@ -584,9 +584,9 @@ public function __call($name, $params)
{
if (strpos($name, 'is') === 0) {
$type = strtolower(substr($name, 2));
array_unshift($params, $type);
return call_user_func_array([$this, 'is'], $params);
}
throw new BadMethodCallException(sprintf('Method %s does not exist', $name));
@@ -643,7 +643,7 @@ public function is($type)
return count(array_filter($result)) > 0;
}
$args = func_get_args();
array_shift($args);
@@ -655,7 +655,7 @@ public function is($type)
if ($args) {
return $this->_is($type, $args);
}
if (!isset($this->_detectorCache[$type])) {
$this->_detectorCache[$type] = $this->_is($type, $args);
}
@@ -1165,11 +1165,15 @@ protected function _parseAcceptWithQualifier($header)
* Provides a read accessor for `$this->query`. Allows you
* to use a syntax similar to `CakeSession` for reading URL query data.
*
* @param string $name Query string variable name
* @return mixed The value being read
* @param string|null $name Query string variable name or null to read all.
* @return string|array|null The value being read
*/
public function query($name)
public function query($name = null)
{
if ($name === null) {
return $this->query;
}
return Hash::get($this->query, $name);
}
@@ -2000,9 +2000,10 @@ public function testEnvironmentDetection($name, $env, $expected)
*/
public function testQuery()
{
$request = new Request([
$array = [
'query' => ['foo' => 'bar', 'zero' => '0']
]);
];
$request = new Request($array);
$result = $request->query('foo');
$this->assertSame('bar', $result);
@@ -2012,6 +2013,9 @@ public function testQuery()
$result = $request->query('imaginary');
$this->assertNull($result);
$result = $request->query();
$this->assertSame($array['query'], $result);
}
/**

0 comments on commit f5bf476

Please sign in to comment.
You can’t perform that action at this time.