public function getQuery($model)
    {
        if ($this->query !== null) {
            return $this->query;
        }

        $this->query = $this->createQuery($model);
        if (!empty($this->activeQueries)) {
            $this->query->setActiveQueries($this->activeQueries);
        }

        $params = Yii::$app->request->queryParams;
        if (isset($params['query']) && !isset($params['ids'])) {
            $this->query->setActiveQueries($params['query']);
        }

        if (isset($params['search']['search-term']) && is_string($params['search']['search-term'])) {
            $this->query->quickSearchPhrase = $params['search']['search-term'];
        }

        if (isset($params['search']) && is_string($params['search'])) {
            $this->query->quickSearchPhrase = $params['search'];
        }

        // add extra authorization conditions
        if ($model->getBehavior('authorizer')) {
            $checkedRelations = $model->getCheckedRelations(Yii::$app->user->id, $this->modelClass . '.read');
            $this->query->authorized($model, $checkedRelations, Yii::$app->user->getIdentity());
        }

        if ($model instanceof ActiveSearchInterface) {
            $model->addConditions($this->query);
        }

        return $this->query;
    }
public function getQuery($model)
    {
        if ($this->query !== null) {
            return $this->query;
        }

        $this->query = $this->createQuery($model);
        if (!empty($this->activeQueries)) {
            $this->query->setActiveQueries($this->activeQueries);
        }

        $params = Yii::$app->request->queryParams;
        if (isset($params['query']) && !isset($params['ids'])) {
            $this->query->setActiveQueries($params['query']);
        }

        if (isset($params['search']['search-term']) && is_string($params['search']['search-term'])) {
            $this->query->quickSearchPhrase = $params['search']['search-term'];
        }

        if (isset($params['search']) && is_string($params['search'])) {
            $this->query->quickSearchPhrase = $params['search'];
        }

        // add extra authorization conditions
        if ($model->getBehavior('authorizer')) {
            $checkedRelations = $model->getCheckedRelations(Yii::$app->user->id, $this->modelClass . '.read');
            $this->query->authorized($model, $checkedRelations, Yii::$app->user->getIdentity());
        }

        if ($model instanceof ActiveSearchInterface) {
            $model->addConditions($this->query);
        }

        return $this->query;
    }
public function getQuery ( $ model ) { if ( $ this -> query !== null ) { return $ this -> query ; } $ this -> query = $ this -> createQuery ( $ model ) ; if ( ! empty ( $ this -> activeQueries ) ) { $ this -> query -> setActiveQueries ( $ this -> activeQueries ) ; } $ params = Yii :: $ app -> request -> queryParams ; if ( isset ( $ params [ 'query' ] ) && ! isset ( $ params [ 'ids' ] ) ) { $ this -> query -> setActiveQueries ( $ params [ 'query' ] ) ; } if ( isset ( $ params [ 'search' ] [ 'search-term' ] ) && is_string ( $ params [ 'search' ] [ 'search-term' ] ) ) { $ this -> query -> quickSearchPhrase = $ params [ 'search' ] [ 'search-term' ] ; } if ( isset ( $ params [ 'search' ] ) && is_string ( $ params [ 'search' ] ) ) { $ this -> query -> quickSearchPhrase = $ params [ 'search' ] ; } // add extra authorization conditions if ( $ model -> getBehavior ( 'authorizer' ) ) { $ checkedRelations = $ model -> getCheckedRelations ( Yii :: $ app -> user -> id , $ this -> modelClass . '.read' ) ; $ this -> query -> authorized ( $ model , $ checkedRelations , Yii :: $ app -> user -> getIdentity ( ) ) ; } if ( $ model instanceof ActiveSearchInterface ) { $ model -> addConditions ( $ this -> query ) ; } return $ this -> query ; }
Returns an ActiveQuery configured using request query params and current user identity.
@param \yii\db\ActiveRecord $model
@return \yii\db\ActiveQuery
Returns an ActiveQuery configured using request query params and current user identity .