framework/data/Sort.php
public function createUrl($attribute, $absolute = false)
    {
        if (($params = $this->params) === null) {
            $request = Yii::$app->getRequest();
            $params = $request instanceof Request ? $request->getQueryParams() : [];
        }
        $params[$this->sortParam] = $this->createSortParam($attribute);
        $params[0] = $this->route === null ? Yii::$app->controller->getRoute() : $this->route;
        $urlManager = $this->urlManager === null ? Yii::$app->getUrlManager() : $this->urlManager;
        if ($absolute) {
            return $urlManager->createAbsoluteUrl($params);
        }

        return $urlManager->createUrl($params);
    }
public function createUrl($attribute, $absolute = false)
    {
        if (($params = $this->params) === null) {
            $request = Yii::$app->getRequest();
            $params = $request instanceof Request ? $request->getQueryParams() : [];
        }
        $params[$this->sortParam] = $this->createSortParam($attribute);
        $params[0] = $this->route === null ? Yii::$app->controller->getRoute() : $this->route;
        $urlManager = $this->urlManager === null ? Yii::$app->getUrlManager() : $this->urlManager;
        if ($absolute) {
            return $urlManager->createAbsoluteUrl($params);
        }

        return $urlManager->createUrl($params);
    }
public function createUrl ( $ attribute , $ absolute = false ) { if ( ( $ params = $ this -> params ) === null ) { $ request = Yii :: $ app -> getRequest ( ) ; $ params = $ request instanceof Request ? $ request -> getQueryParams ( ) : [ ] ; } $ params [ $ this -> sortParam ] = $ this -> createSortParam ( $ attribute ) ; $ params [ 0 ] = $ this -> route === null ? Yii :: $ app -> controller -> getRoute ( ) : $ this -> route ; $ urlManager = $ this -> urlManager === null ? Yii :: $ app -> getUrlManager ( ) : $ this -> urlManager ; if ( $ absolute ) { return $ urlManager -> createAbsoluteUrl ( $ params ) ; } return $ urlManager -> createUrl ( $ params ) ; }
Creates a URL for sorting the data by the specified attribute.
This method will consider the current sorting status given by [[attributeOrders]].
For example, if the current page already sorts the data by the specified attribute in ascending order,
then the URL created will lead to a page that sorts the data by the specified attribute in descending order.
@param string $attribute the attribute name
@param bool $absolute whether to create an absolute URL. Defaults to `false`.
@return string the URL for sorting. False if the attribute is invalid.
@throws InvalidConfigException if the attribute is unknown
@see attributeOrders
@see params
Creates a URL for sorting the data by the specified attribute . This method will consider the current sorting status given by [[ attributeOrders ]] . For example if the current page already sorts the data by the specified attribute in ascending order then the URL created will lead to a page that sorts the data by the specified attribute in descending order .