Create ActiveDataProvider.
@return \yii\data\ActiveDataProvider
509732
protected function createDataProvider() : ActiveDataProvider
    {
        $query = $this->buildQuery();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort'  => [
                'defaultOrder' => $this->defaultOrder
            ]
        ]);

        if (!$this->load($this->requestData())) {
            return $dataProvider;
        }
        if (!$this->validate()) {
            $query->where('0=1');
            return $dataProvider;
        }
        $this->buildFilter($query);

        return $dataProvider;
    }
280792
public function prepareDataProvider(IndexAction $action, $filter)
    {
        /* @var $modelClass \yii\db\BaseActiveRecord */
        $modelClass = $this->modelClass;

        $query = $modelClass::find();
        if (!empty($filter)) {
            $query->andWhere($filter);
        }
        return Yii::createObject([
            'class' => ActiveDataProvider::class,
            'query' => $query,
            'sort' => [
                'defaultOrder' => [
                    'created_at' => SORT_DESC,
                    'id' => SORT_ASC,
                ]
            ],
        ]);
    }
1172955
public function actionCreate()
    {
        Yii::$app->getResponse()->format = 'json';
        $routes = Yii::$app->getRequest()->post('route', '');
        $routes = preg_split('/\s*,\s*/', trim($routes), -1, PREG_SPLIT_NO_EMPTY);
        $model = new Route();
        $model->addNew($routes);
        return $model->getRoutes();
    }
1127371
public function search()
    {
        $criteria = new CDbCriteria;

        $criteria->compare('t.id', $this->id);
        $criteria->compare('t.name', $this->name, true);
        $criteria->compare('t.subject', $this->subject, true);
        $criteria->compare('t.heading', $this->heading, true);
        $criteria->compare('t.message', $this->message, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
            'sort' => array(
                'defaultOrder' => 'id DESC',
            ),
        ));
    }
313992
public function search($params)
    {
        $query = AuthRule::find();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);
        if (!($this->load($params) && $this->validate())) {
            return $dataProvider;
        }
        $query->andFilterWhere([
                'created_at' => $this->created_at,
                'updated_at' => $this->updated_at,
            ]);
        $query->andFilterWhere(['like', 'name', $this->name])
            ->andFilterWhere(['like', 'data', $this->data]);
        return $dataProvider;
    }
299607
protected function getProviderData()
    {
        $models = $this->data->getModels();
        $data = [];
        foreach ($models as $model) {
            $row = $model instanceof Model ? $model->attributes : $model;
            if ($this->attributes) {
                $values = [];
                foreach ($this->attributes as $attr) {
                    $values[$attr] = $row[$attr];
                }
                $row = $values;
            }
            $data [] = array_values($row);
        }
        return $data;
    }
434258
public function search($params)
    {
        $query = Stat::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id,
            'creation_time' => $this->creation_time,
            'ip' => $this->ip,
            'user_id' => $this->user_id,
        ]);

        $query->andFilterWhere(['like', 'module', $this->module]);
        $query->andFilterWhere(['like', 'controller', $this->controller]);
        $query->andFilterWhere(['like', 'action', $this->action]);

        return $dataProvider;
    }
997541
public function actionIndex()
    {
        $request = \Yii::$app->request;
        if ($request->getIsOptions()) {
            return $this->ResponseOptions($this->verbs()['index']);
        }
        try{
            $searchModel = new UserSearch();
            $dataProvider = $searchModel->search(Yii::$app->request->queryParams);

            return $dataProvider;
        }catch(Exception $e)
        {
            throw new Exception($e);
        }


    }
653133
public function search($params)
    {
        /* @var $query \yii\db\ActiveQuery */
        $class = Yii::$app->getUser()->identityClass ? : 'mdm\admin\models\User';
        $query = $class::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);
        if (!$this->validate()) {
            $query->where('1=0');
            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id,
            'status' => $this->status,
        ]);

        $query->andFilterWhere(['like', 'username', $this->username])
            ->andFilterWhere(['like', 'email', $this->email]);

        return $dataProvider;
    }
994750
private function getActiveModel()
    {
        $input = $this->getEnvironment()->getInputProvider();
        if (false === $input->hasParameter('id')) {
            return null;
        }

        $modelId      = ModelId::fromSerialized($input->getParameter('id'));
        $dataProvider = $this->getEnvironment()->getDataProvider($modelId->getDataProviderName());

        $model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId()));

        return $model;
    }
954750
public function search($params)
    {
        $query = Language::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        if (!($this->load($params) && $this->validate())) {
            return $dataProvider;
        }

        $query->andFilterWhere([
            'status' => $this->status,
        ]);

        $query->andFilterWhere($this->createLikeExpression('language_id', $this->language_id))
            ->andFilterWhere($this->createLikeExpression('language', $this->language))
            ->andFilterWhere($this->createLikeExpression('country', $this->country))
            ->andFilterWhere($this->createLikeExpression('name', $this->name))
            ->andFilterWhere($this->createLikeExpression('name_ascii', $this->name_ascii));

        return $dataProvider;
    }
31207
public function createDataProvider($modelForm)
    {
        $query = new Query;
        $this->prepareCondition($query, $modelForm);
        $count = $query->from("audits.{$modelForm->table}")->count();
        $query = new Query;
        $this->prepareCondition($query, $modelForm);
        $columns = $this->getRelations($query, $modelForm->table);
        $columns[] = 'audit.*';

        $query->select(join(', ', $columns))->from("audits.{$modelForm->table} audit");
        $dataProvider = new \yii\data\ActiveDataProvider([
            'query' => $query,
            'totalCount' => $count,
            'sort' => [
                'attributes' => ['operation_date'],
            ],
            'pagination' => [
                'pageSize' => 10,
            ],
        ]);
        return $dataProvider;
    }
606337
public function actionIndex()
    {
        $where = ['type' => Article::ARTICLE];
        $query = Article::find()->select([])->where($where);
        $keyword = htmlspecialchars(yii::$app->getRequest()->get('q'));
        $query->andFilterWhere(['like', 'title', $keyword]);
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort' => [
                'defaultOrder' => [
                    'sort' => SORT_ASC,
                    'id' => SORT_DESC,
                ]
            ]
        ]);
        return $this->render('/article/index', [
            'dataProvider' => $dataProvider,
            'type' => yii::t('cms', 'Search keyword {keyword} results', ['keyword'=>$keyword]),
        ]);
    }
118794
public function actionIndex() {
    $roles = Yii::$app->authManager->getRoles();
    $dataProvider = new ArrayDataProvider(['allModels' => $roles]);
    return $this->render('index', [
      'dataProvider' => $dataProvider,
    ]);
  }
391994
public function getActiveProvider()
    {
        if ($this->activeProvider instanceof ProviderInterface) {
            return $this->activeProvider;
        }

        if (empty($this->providers)) {
            throw new RuntimeException('No versioning provider found');
        }

        foreach ($this->providers as $entry) {
            $provider = $entry['provider'];
            /** @var $provider ProviderInterface */
            if ($provider->isSupported()) {
                $this->activeProvider = $provider;

                return $provider;
            }
        }

        throw new RuntimeException('No supported versioning providers found');
    }
1326566
public function getActiveWindowObject()
    {
        if ($this->_activeWindowObject === null) {
            $activeWindow = $this->findActiveWindow($this->activeWindowHash);
            $object = Yii::createObject($activeWindow['objectConfig']);
            $object->setItemId($this->itemId);
            $object->setConfigHash($this->config->getHash());
            $object->setActiveWindowHash($this->activeWindowHash);
            Yii::$app->session->set($this->activeWindowHash, $this->itemId);
            $this->_activeWindowObject = $object;
        }
        
        return $this->_activeWindowObject;
    }
1360601
public function actionCreate()
    {
        $this->layout = static::FORM_LAYOUT;
        $model = new $this->MainModel;

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            $this->afterCreate($model);
            if ($this->hasView) {
                return $this->redirect(['view', 'id' => $model->id]);
            } else {
                return $this->redirect(['index']);
            }
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }