Commit 1ae4103b by Carsten Brandt

fixed Sort::params to be retrieved from Request instead of $_GET

for consistency with paginiation
parent 454a9ee5
...@@ -12,6 +12,7 @@ use yii\base\InvalidConfigException; ...@@ -12,6 +12,7 @@ use yii\base\InvalidConfigException;
use yii\base\Object; use yii\base\Object;
use yii\helpers\Html; use yii\helpers\Html;
use yii\helpers\Inflector; use yii\helpers\Inflector;
use yii\web\Request;
/** /**
* Sort represents information relevant to sorting. * Sort represents information relevant to sorting.
...@@ -240,7 +241,10 @@ class Sort extends Object ...@@ -240,7 +241,10 @@ class Sort extends Object
{ {
if ($this->_attributeOrders === null || $recalculate) { if ($this->_attributeOrders === null || $recalculate) {
$this->_attributeOrders = []; $this->_attributeOrders = [];
$params = $this->params === null ? $_GET : $this->params; if (($params = $this->params) === null) {
$request = Yii::$app->getRequest();
$params = $request instanceof Request ? $request->get() : [];
}
if (isset($params[$this->sortVar]) && is_scalar($params[$this->sortVar])) { if (isset($params[$this->sortVar]) && is_scalar($params[$this->sortVar])) {
$attributes = explode($this->separators[0], $params[$this->sortVar]); $attributes = explode($this->separators[0], $params[$this->sortVar]);
foreach ($attributes as $attribute) { foreach ($attributes as $attribute) {
...@@ -332,7 +336,10 @@ class Sort extends Object ...@@ -332,7 +336,10 @@ class Sort extends Object
*/ */
public function createUrl($attribute) public function createUrl($attribute)
{ {
$params = $this->params === null ? $_GET : $this->params; if (($params = $this->params) === null) {
$request = Yii::$app->getRequest();
$params = $request instanceof Request ? $request->get() : [];
}
$params[$this->sortVar] = $this->createSortVar($attribute); $params[$this->sortVar] = $this->createSortVar($attribute);
$route = $this->route === null ? Yii::$app->controller->getRoute() : $this->route; $route = $this->route === null ? Yii::$app->controller->getRoute() : $this->route;
$urlManager = $this->urlManager === null ? Yii::$app->getUrlManager() : $this->urlManager; $urlManager = $this->urlManager === null ? Yii::$app->getUrlManager() : $this->urlManager;
......
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