mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Making it so all POST parameters are available on $this->data inside the request. This makes one fewer place POST data
is found. $this->params['form'] is still around as well for Backwards compatibility, but is not recommended for use going forward.
This commit is contained in:
parent
60ee04a0fb
commit
975f74bb44
2 changed files with 17 additions and 5 deletions
|
@ -133,6 +133,8 @@ class CakeRequest implements ArrayAccess {
|
|||
|
||||
/**
|
||||
* process the post data and set what is there into the object.
|
||||
* The raw post is available at $this->params['form'], while a lightly processed
|
||||
* version is available at $this->data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -150,11 +152,12 @@ class CakeRequest implements ArrayAccess {
|
|||
} else {
|
||||
$_ENV['REQUEST_METHOD'] = $this->params['form']['_method'];
|
||||
}
|
||||
unset($this->params['form']['_method']);
|
||||
}
|
||||
if (isset($this->params['form']['data'])) {
|
||||
$this->data = $this->params['form']['data'];
|
||||
unset($this->params['form']['data']);
|
||||
$this->data = $this->params['form'];
|
||||
if (isset($this->data['data'])) {
|
||||
$data = $this->data['data'];
|
||||
unset($this->data['data']);
|
||||
$this->data = Set::merge($this->data, $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -533,6 +536,14 @@ class CakeRequest implements ArrayAccess {
|
|||
|
||||
/**
|
||||
* Get the HTTP method used for this request.
|
||||
* There are a few ways to specify a method.
|
||||
*
|
||||
* - If your client supports it you can use native HTTP methods.
|
||||
* - You can set the HTTP-X-Method-Override header.
|
||||
* - You can submit an input with the name `_method`
|
||||
*
|
||||
* Any of these 3 approaches can be used to set the HTTP method used
|
||||
* by CakePHP internally, and will effect the result of this method.
|
||||
*
|
||||
* @return string The name of the HTTP method used.
|
||||
*/
|
||||
|
|
|
@ -160,7 +160,8 @@ class CakeRequestTestCase extends CakeTestCase {
|
|||
|
||||
$_POST = array('one' => 1, 'two' => 'three');
|
||||
$request = new CakeRequest('some/path');
|
||||
$this->assertEqual($request->params['form'], $_POST);
|
||||
$this->assertEquals($_POST, $request->params['form']);
|
||||
$this->assertEquals($_POST, $request->data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue