Commit f1a674b9 by Alexander Makarov

Added `yii\web\Request::get($name = null, $defaultValue = null)` and…

Added `yii\web\Request::get($name = null, $defaultValue = null)` and `yii\web\Request::post($name = null, $defaultValue = null)`
parent 8c7ae47e
...@@ -118,9 +118,11 @@ Yii Framework 2 Change Log ...@@ -118,9 +118,11 @@ Yii Framework 2 Change Log
- Chg #1852: DbConnection::tablePrefix default value now 'tbl_' (creocoder) - Chg #1852: DbConnection::tablePrefix default value now 'tbl_' (creocoder)
- Chg #1958: `beforeSubmit` in `yii.activeform` is now executed after validation and before form submission (6pblcb) - Chg #1958: `beforeSubmit` in `yii.activeform` is now executed after validation and before form submission (6pblcb)
- Chg #2025: Removed ability to declare scopes in ActiveRecord (samdark) - Chg #2025: Removed ability to declare scopes in ActiveRecord (samdark)
- Chg #2043: Renamed `yii\web\Request::acceptedLanguages` to `acceptableLanguages` (qiangxue) - Chg #2043:
- Chg #2043: Removed `yii\web\Request::getPost()`, `getPut()`, `getDelete()`, `getPatch()` in favor of `getBodyParam()` (cebe) - Renamed `yii\web\Request::acceptedLanguages` to `acceptableLanguages` (qiangxue)
- Chg #2043: Renamed `yii\web\Request::get()` to `getQueryParams()` and `getRestParams()` to `getBodyParams()` (cebe) - Removed `yii\web\Request::getPost()`, `getPut()`, `getDelete()`, `getPatch()` in favor of `getBodyParam()` (cebe)
- Renamed `yii\web\Request::get()` to `getQueryParams()` and `getRestParams()` to `getBodyParams()` (cebe)
- Added `yii\web\Request::get($name = null, $defaultValue = null)` and `yii\web\Request::post($name = null, $defaultValue = null)` (samdark)
- Chg #2057: AutoTimestamp attributes defaults changed from `create_time` and `update_time` to `created_at` and `updated_at` (creocoder) - Chg #2057: AutoTimestamp attributes defaults changed from `create_time` and `update_time` to `created_at` and `updated_at` (creocoder)
- Chg #2059: Implemented git-flavored file excluding/filtering for `FileHelper` (nineinchnick) - Chg #2059: Implemented git-flavored file excluding/filtering for `FileHelper` (nineinchnick)
- Chg #2063: Removed `yii\web\Request::acceptTypes` and renamed `yii\web\Request::acceptedContentTypes` to `acceptableContentTypes` (qiangxue) - Chg #2063: Removed `yii\web\Request::acceptTypes` and renamed `yii\web\Request::acceptedContentTypes` to `acceptableContentTypes` (qiangxue)
......
...@@ -380,6 +380,22 @@ class Request extends \yii\base\Request ...@@ -380,6 +380,22 @@ class Request extends \yii\base\Request
return isset($params[$name]) ? $params[$name] : $defaultValue; return isset($params[$name]) ? $params[$name] : $defaultValue;
} }
/**
* Returns POST parameter with a given name. If name isn't specified, returns an array of all POST parameters.
*
* @param string $name the parameter name
* @param mixed $defaultValue the default parameter value if the parameter does not exist.
* @return array|mixed
*/
public function post($name = null, $defaultValue = null)
{
if ($name === null) {
return $this->getBodyParams();
} else {
return $this->getBodyParam($name, $defaultValue);
}
}
private $_queryParams; private $_queryParams;
/** /**
...@@ -409,6 +425,22 @@ class Request extends \yii\base\Request ...@@ -409,6 +425,22 @@ class Request extends \yii\base\Request
} }
/** /**
* Returns GET parameter with a given name. If name isn't specified, returns an array of all GET parameters.
*
* @param string $name the parameter name
* @param mixed $defaultValue the default parameter value if the parameter does not exist.
* @return array|mixed
*/
public function get($name = null, $defaultValue = null)
{
if ($name === null) {
return $this->getQueryParams();
} else {
return $this->getQueryParam($name, $defaultValue);
}
}
/**
* Returns the named GET parameter value. * Returns the named GET parameter value.
* If the GET parameter does not exist, the second parameter to this method will be returned. * If the GET parameter does not exist, the second parameter to this method will be returned.
* @param string $name the GET parameter name. If not specified, whole $_GET is returned. * @param string $name the GET parameter name. If not specified, whole $_GET is returned.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment