Commit 7ae8b8b5 by Carsten Brandt

added support to parse json request to Request::getRestParams()

parent 2be2e458
...@@ -86,6 +86,7 @@ Yii Framework 2 Change Log ...@@ -86,6 +86,7 @@ Yii Framework 2 Change Log
- Enh: Added `TableSchema::fullName` property (qiangxue) - Enh: Added `TableSchema::fullName` property (qiangxue)
- Enh #1839: Added support for getting file extension and basename from uploaded file (anfrantic) - Enh #1839: Added support for getting file extension and basename from uploaded file (anfrantic)
- Enh: yii\codeception\TestCase now supports loading and using fixtures via Yii fixture framework (qiangxue) - Enh: yii\codeception\TestCase now supports loading and using fixtures via Yii fixture framework (qiangxue)
- Enh: Added support to parse json request data to Request::getRestParams() (cebe)
- Chg #1519: `yii\web\User::loginRequired()` now returns the `Response` object instead of exiting the application (qiangxue) - Chg #1519: `yii\web\User::loginRequired()` now returns the `Response` object instead of exiting the application (qiangxue)
- Chg #1586: `QueryBuilder::buildLikeCondition()` will now escape special characters and use percentage characters by default (qiangxue) - Chg #1586: `QueryBuilder::buildLikeCondition()` will now escape special characters and use percentage characters by default (qiangxue)
- Chg #1610: `Html::activeCheckboxList()` and `Html::activeRadioList()` will submit an empty string if no checkbox/radio is selected (qiangxue) - Chg #1610: `Html::activeCheckboxList()` and `Html::activeRadioList()` will submit an empty string if no checkbox/radio is selected (qiangxue)
......
...@@ -10,6 +10,7 @@ namespace yii\web; ...@@ -10,6 +10,7 @@ namespace yii\web;
use Yii; use Yii;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
use yii\base\InvalidParamException; use yii\base\InvalidParamException;
use yii\helpers\Json;
use yii\helpers\Security; use yii\helpers\Security;
use yii\helpers\StringHelper; use yii\helpers\StringHelper;
...@@ -256,6 +257,8 @@ class Request extends \yii\base\Request ...@@ -256,6 +257,8 @@ class Request extends \yii\base\Request
if ($this->_restParams === null) { if ($this->_restParams === null) {
if (isset($_POST[$this->restVar])) { if (isset($_POST[$this->restVar])) {
$this->_restParams = $_POST; $this->_restParams = $_POST;
} elseif(strncmp($this->getContentType(), 'application/json', 16) === 0) {
$this->_restParams = Json::decode($this->getRawBody(), true);
} else { } else {
$this->_restParams = []; $this->_restParams = [];
mb_parse_str($this->getRawBody(), $this->_restParams); mb_parse_str($this->getRawBody(), $this->_restParams);
......
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