We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yii\data\Sort:
/** * Returns the currently requested sort information. * @param bool $recalculate whether to recalculate the sort directions * @return array sort directions indexed by attribute names. * Sort direction can be either `SORT_ASC` for ascending order or * `SORT_DESC` for descending order. */ public function getAttributeOrders($recalculate = false) { if ($this->_attributeOrders === null || $recalculate) { $this->_attributeOrders = []; if (($params = $this->params) === null) { $request = Yii::$app->getRequest(); $params = $request instanceof Request ? $request->getQueryParams() : []; } //反馈:这里当存在排序参数并且排序参数为空时,也会执行下面的代码,从而导致无法执行最后的默认排序, //当我想继承这个Sort类,对这部分代码进行部分修改时,private _attributeOrders 属性又限制对这个方法的部分代码修改, //建议:将 isset($params[$this->sortParam]) 改为 isset($params[$this->sortParam])&&empty(isset($params[$this->sortParam])) 或者其他 if (isset($params[$this->sortParam])) { foreach ($this->parseSortParam($params[$this->sortParam]) as $attribute) { $descending = false; if (strncmp($attribute, '-', 1) === 0) { $descending = true; $attribute = substr($attribute, 1); } if (isset($this->attributes[$attribute])) { $this->_attributeOrders[$attribute] = $descending ? SORT_DESC : SORT_ASC; if (!$this->enableMultiSort) { return $this->_attributeOrders; } } } return $this->_attributeOrders; } if (empty($this->_attributeOrders) && is_array($this->defaultOrder)) { $this->_attributeOrders = $this->defaultOrder; } } return $this->_attributeOrders; }
The text was updated successfully, but these errors were encountered:
I'm not sure why it was done like that, I think we should indeed check isset and empty.
Sorry, something went wrong.
Do you have time for a pull request?
Here is a little busy, it can only be submitted slightly later.
I think supposedly fallback defaultOrder if empty string, am I correct ?
[ 'params' => [ 'sort' => '' ]]
No branches or pull requests
What steps will reproduce the problem?
yii\data\Sort:
The text was updated successfully, but these errors were encountered: