Commit 150d7136 by Qiang Xue

Merge branch 'request-params-refactoring' of github.com:cebe/yii2 into…

Merge branch 'request-params-refactoring' of github.com:cebe/yii2 into cebe-request-params-refactoring Conflicts: framework/CHANGELOG.md
parents d8a4b762 7438b6b4
......@@ -100,7 +100,7 @@ class Nav extends Widget
$this->route = Yii::$app->controller->getRoute();
}
if ($this->params === null) {
$this->params = $_GET;
$this->params = Yii::$app->request->getQueryParams();
}
Html::addCssClass($this->options, 'nav');
}
......
......@@ -25,10 +25,15 @@ ul.trace {
}
td, th {
white-space: pre-line;
white-space: pre-wrap;
word-wrap: break-word;
}
.request-table td {
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
word-break: break-all;
}
.detail-grid-view th {
white-space: nowrap;
}
......
......@@ -53,7 +53,7 @@ class DbPanel extends Panel
public function getDetail()
{
$searchModel = new Db();
$dataProvider = $searchModel->search(Yii::$app->request->get(), $this->getModels());
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams(), $this->getModels());
return Yii::$app->view->render('panels/db/detail', [
'panel' => $this,
......
......@@ -39,7 +39,7 @@ class LogPanel extends Panel
public function getDetail()
{
$searchModel = new Log();
$dataProvider = $searchModel->search(Yii::$app->request->get(), $this->getModels());
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams(), $this->getModels());
return Yii::$app->view->render('panels/log/detail', [
'dataProvider' => $dataProvider,
......
......@@ -42,7 +42,7 @@ class ProfilingPanel extends Panel
public function getDetail()
{
$searchModel = new Profile();
$dataProvider = $searchModel->search(Yii::$app->request->get(), $this->getModels());
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams(), $this->getModels());
return Yii::$app->view->render('panels/profile/detail', [
'panel' => $this,
......
......@@ -82,6 +82,11 @@ class RequestPanel extends Panel
'route' => Yii::$app->requestedAction ? Yii::$app->requestedAction->getUniqueId() : Yii::$app->requestedRoute,
'action' => $action,
'actionParams' => Yii::$app->requestedParams,
'requestBody' => Yii::$app->getRequest()->getRawBody() == '' ? [] : [
'Content Type' => Yii::$app->getRequest()->getContentType(),
'Raw' => Yii::$app->getRequest()->getRawBody(),
'Decoded to Params' => Yii::$app->getRequest()->getBodyParams(),
],
'SERVER' => empty($_SERVER) ? [] : $_SERVER,
'GET' => empty($_GET) ? [] : $_GET,
'POST' => empty($_POST) ? [] : $_POST,
......
......@@ -13,7 +13,8 @@ echo Tabs::widget([
. $this->render('panels/request/table', ['caption' => '$_GET', 'values' => $panel->data['GET']])
. $this->render('panels/request/table', ['caption' => '$_POST', 'values' => $panel->data['POST']])
. $this->render('panels/request/table', ['caption' => '$_FILES', 'values' => $panel->data['FILES']])
. $this->render('panels/request/table', ['caption' => '$_COOKIE', 'values' => $panel->data['COOKIE']]),
. $this->render('panels/request/table', ['caption' => '$_COOKIE', 'values' => $panel->data['COOKIE']])
. $this->render('panels/request/table', ['caption' => 'Request Body', 'values' => $panel->data['requestBody']]),
'active' => true,
],
[
......
......@@ -15,7 +15,7 @@ use yii\helpers\VarDumper;
<?php else: ?>
<table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;">
<table class="table table-condensed table-bordered table-striped table-hover request-table" style="table-layout: fixed;">
<thead>
<tr>
<th style="width: 200px;">Name</th>
......
......@@ -59,7 +59,7 @@ class <?= $controllerClass ?> extends <?= StringHelper::basename($generator->bas
public function actionIndex()
{
$searchModel = new <?= isset($searchModelAlias) ? $searchModelAlias : $searchModelClass ?>;
$dataProvider = $searchModel->search($_GET);
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());
return $this->render('index', [
'dataProvider' => $dataProvider,
......
......@@ -118,6 +118,9 @@ Yii Framework 2 Change Log
- 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 #2025: Removed ability to declare scopes in ActiveRecord (samdark)
- Chg #2043: Renamed `yii\web\Request::acceptedLanguages` to `acceptableLanguages` (qiangxue)
- Chg #2043: Removed `yii\web\Request::getPut()`, `getDelete()`, `getPatch()` in favor of `getBodyParam()` (cebe)
- Chg #2043: Renamed `yii\web\Request::get()` to `getQueryParams()` and `getRestParams()` to `getBodyParams()` (cebe)
- Chg #2057: AutoTimestamp attributes defaults changed from `create_time` and `update_time` to `created_at` and `updated_at` (creocoder)
- Chg #2063: Removed `yii\web\Request::acceptTypes` and renamed `yii\web\Request::acceptedContentTypes` to `acceptableContentTypes` (qiangxue)
- Chg #2157: The '*' category pattern will match all categories that do not match any other patterns listed in `I18N::translations` (qiangxue, Ragazzo)
......
......@@ -141,7 +141,7 @@ class Pagination extends Object
if ($this->_page === null || $recalculate) {
if (($params = $this->params) === null) {
$request = Yii::$app->getRequest();
$params = $request instanceof Request ? $request->get() : [];
$params = $request instanceof Request ? $request->getQueryParams() : [];
}
if (isset($params[$this->pageVar]) && is_scalar($params[$this->pageVar])) {
$this->_page = (int)$params[$this->pageVar] - 1;
......@@ -183,7 +183,7 @@ class Pagination extends Object
{
if (($params = $this->params) === null) {
$request = Yii::$app->getRequest();
$params = $request instanceof Request ? $request->get() : [];
$params = $request instanceof Request ? $request->getQueryParams() : [];
}
if ($page > 0 || $page >= 0 && $this->forcePageVar) {
$params[$this->pageVar] = $page + 1;
......
......@@ -245,7 +245,7 @@ class Sort extends Object
$this->_attributeOrders = [];
if (($params = $this->params) === null) {
$request = Yii::$app->getRequest();
$params = $request instanceof Request ? $request->get() : [];
$params = $request instanceof Request ? $request->getQueryParams() : [];
}
if (isset($params[$this->sortVar]) && is_scalar($params[$this->sortVar])) {
$attributes = explode($this->separators[0], $params[$this->sortVar]);
......@@ -341,7 +341,7 @@ class Sort extends Object
{
if (($params = $this->params) === null) {
$request = Yii::$app->getRequest();
$params = $request instanceof Request ? $request->get() : [];
$params = $request instanceof Request ? $request->getQueryParams() : [];
}
$params[$this->sortVar] = $this->createSortVar($attribute);
$route = $this->route === null ? Yii::$app->controller->getRoute() : $this->route;
......
......@@ -237,7 +237,7 @@ class BaseHtml
if ($request instanceof Request) {
if (strcasecmp($method, 'get') && strcasecmp($method, 'post')) {
// simulate PUT, DELETE, etc. via POST
$hiddenInputs[] = static::hiddenInput($request->restVar, $method);
$hiddenInputs[] = static::hiddenInput($request->methodVar, $method);
$method = 'post';
}
if ($request->enableCsrfValidation && !strcasecmp($method, 'post')) {
......
......@@ -217,7 +217,7 @@ class UrlManager extends Component
return [$pathInfo, []];
} else {
Yii::trace('Pretty URL not enabled. Using default URL parsing logic.', __METHOD__);
$route = $request->get($this->routeVar);
$route = $request->getQueryParam($this->routeVar, '');
if (is_array($route)) {
$route = '';
}
......
......@@ -158,7 +158,7 @@ class Menu extends Widget
$this->route = Yii::$app->controller->getRoute();
}
if ($this->params === null) {
$this->params = $_GET;
$this->params = Yii::$app->request->getQueryParams();
}
$items = $this->normalizeItems($this->items, $hasActiveChild);
$options = $this->options;
......
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