Filter container data provider against where conditions

@return array
170216
private function filter()
    {
        $containerData = $this->getDataProvider();
        $whereExpression = $this->_where;
        
        if (empty($whereExpression)) {
            $data = $containerData;
        } else {
            $data = array_filter($containerData, function ($item) {
                foreach ($item as $field => $value) {
                    if (!$this->arrayFilter($value, $field)) {
                        return false;
                    }
                }
        
                return true;
            });
        }
        
        if ($this->_offset !== null) {
            $data = array_slice($data, $this->_offset, null, true);
        }

        if ($this->_limit !== null) {
            $data = array_slice($data, 0, $this->_limit, true);
        }
        
        if ($this->_binds) {
            foreach ($this->_binds as $id => $values) {
                if (isset($data[$id])) {
                    $data[$id] = array_merge($data[$id], $values);
                }
            }
        }

        return $data;
    }
552422
protected function _getFilterData()
    {
        $rawFilterData = $this->request->getData();
        $filterData = [];
        foreach ($this->filterFields as $filterField => $options) {
            if (isset($rawFilterData[$filterField]) && $rawFilterData[$filterField] !== '') {
                $filterData[$filterField] = $rawFilterData[$filterField];
            }
        }

        return $filterData;
    }
1080950
private function getFilters()
    {
        $filters = [];

        $regions = [
            'fieldID' => 'region_id',
            'type' => 'dropDownList',
            'label' => trans('HCRegions::regions_countries.region'),
            'options' => HCContinents::all()->toArray(),
            'showNodes' => ['name'],
        ];

        $filters[] = addAllOptionToDropDownList($regions);

        return $filters;
    }
499938
public function search($params)
    {
        $query = Authentication::find()->with('user');

        // add conditions that should always apply here

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

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

        // grid filtering conditions
        $query->andFilterWhere([
            'user_id' => $this->user_id,
            'status' => $this->status,
        ]);

        if ($this->created_at !== null) {
            $date = strtotime($this->created_at);
            $query->andWhere(['between', 'created_at', $date, $date + 3600 * 24]);
        }

        if ($this->updated_at !== null) {
            $date = strtotime($this->updated_at);
            $query->andWhere(['between', 'updated_at', $date, $date + 3600 * 24]);
        }

        $query->andFilterWhere(['like', 'real_name', $this->real_name])
            ->andFilterWhere(['like', 'id_card', $this->id_card]);

        return $dataProvider;
    }
202836
public function getFilters()
    {
        $language = $this->container->get('language');

        return [
            new \Twig_SimpleFilter('trans', [$language, 'translate']),
            new \Twig_SimpleFilter('lang', [$language, 'translate']),
            new \Twig_SimpleFilter('translate', [$language, 'translate']),
            new \Twig_SimpleFilter('_', [$language, 'translate']),
            new \Twig_SimpleFilter('sprintf', function (...$args) use ($language) {
                return $language->sprintf(...$args);
            }),
            new \Twig_SimpleFilter('plural', function (...$args) use ($language) {
                return $language->plural(...$args);
            }),
        ];
    }
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;
    }
556190
public function getProviders()
	{
		$list = [];
		$this->filter->setConditions( $this->filter->combine( '&&', $this->conditions ) );

		foreach( $this->manager->searchItems( $this->filter, $this->domains ) as $id => $item ) {
			$list[$id] = $this->manager->getProvider( $item, $item->getType() );
		}

		return $list;
	}
176081
public function search($params)
    {
        $query = ShopAttribute::find();

        // add conditions that should always apply here

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

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'type_id' => $this->type_id,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ]);

        return $dataProvider;
    }
437014
public function search($params)
    {
        $query = Project::find();

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

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

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

        $query->andFilterWhere(['like', 'name', $this->name])
            ->andFilterWhere(['like', 'description', $this->description]);

        return $dataProvider;
    }
1083048
public function getFilters()
    {
        $filters = [];

        $names = explode('_', $this->name);
        $base = '';
        $filters = [];
        while ($name = array_shift($names)) {
            $filter = $this->_searchInControllerDir($base, 'filter.yml');
            if ($filter) $filters[] = $filter;

            // when has rest.
            if (count($names) > 0) {
                $base = $base . DS . ucfirst($name);

            // when last.
            } else {
                $filter = $this->_searchInControllerDir($base, "{$name}.filter.yml");
                if ($filter) $filters[] = $filter;
            }
        }

        return $filters;
    }
1064042
public function search($params)
    {
        $query = User::find();

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

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

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

        $query->andFilterWhere(['like', 'username', $this->username])
            ->andFilterWhere(['like', 'auth_key', $this->auth_key])
            ->andFilterWhere(['like', 'password_hash', $this->password_hash])
            ->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])
            ->andFilterWhere(['like', 'email', $this->email])
            ->andFilterWhere(['like', 'full_name', $this->full_name])
            ->andFilterWhere(['like', 'job', $this->job])
            ->andFilterWhere(['like', 'bio', $this->bio])
            ->andFilterWhere(['like', 'company', $this->company])
            ->andFilterWhere(['like', 'tax_number', $this->tax_number])
            ->andFilterWhere(['like', 'address', $this->address])
            ->andFilterWhere(['like', 'avatar', $this->avatar])
            ->andFilterWhere(['like', 'phone', $this->phone])
            ->andFilterWhere(['like', 'facebook_url', $this->facebook_url]);

        return $dataProvider;
    }
1300702
public function filtering()
    {
        if ($this->request->hasHeader('search-protection')) {
            $this->request->setSearchableColumnIndex($this->columns, $this->columnDef['filter']);
        }
        $columns          = $this->request['columns'];
        $this->collection = $this->collection->filter(function ($row) use ($columns) {
            $data                  = $this->serialize($row);
            $this->isFilterApplied = true;
            $found                 = [];

            $keyword = $this->request->keyword();
            foreach ($this->request->searchableColumnIndex() as $index) {
                $column = $this->getColumnName($index);
                if (!$value  = Arr::get($data, $column)) {
                    continue;
                }

                if ($this->isCaseInsensitive()) {
                    $found[] = Str::contains(Str::lower($value), Str::lower($keyword));
                } else {
                    $found[] = Str::contains($value, $keyword);
                }
            }

            return in_array(true, $found);
        }
        );
    }
1084031
public function search($params)
    {
        $query = static::find();

        // add conditions that should always apply here

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

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'pid' => $this->pid,
            'sort_order' => $this->sort_order,
            'status' => $this->status,
        ]);

        $query->andFilterWhere(['like', 'label', $this->label])
            ->andFilterWhere(['like', 'url', $this->url])
            ->andFilterWhere(['like', 'content', $this->content]);

        return $dataProvider;
    }
262595
protected function whereStatement(): array
    {
        $where = parent::whereStatement();

        if (!empty($morphKey = $this->key(Record::MORPH_KEY))) {
            //HasOne relation support additional morph key
            $where['{@}.' . $this->key(Record::MORPH_KEY)] = $this->orm->define(
                get_class($this->parent),
                ORMInterface::R_ROLE_NAME
            );
        }

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

        // add conditions that should always apply here

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

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'iso_639_1' => $this->iso_639_1,
            'iso_639_2' => $this->iso_639_2,
            'iso_639_3' => $this->iso_639_3,
        ]);
        $query->andFilterWhere(['like', 'name', $this->name]);

        return $dataProvider;
    }
436781
public function search($params)
    {
        $query = Setting::find();

        // add conditions that should always apply here

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

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'user_id' => $this->user_id,
            'domain_id' => $this->domain_id,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ]);

        $query->andFilterWhere(['like', 'name', $this->name])
            ->andFilterWhere(['like', 'json_value', $this->json_value]);

        return $dataProvider;
    }
862263
public function filtervalueAction()
    {
        $data = ['roles' => []];

        /*
        foreach ($acl->getResources() as $role) {
            $data['roles'][] = array($role, ucfirst($role));
        }
        */

        $bundles = $this->container->getParameter('kernel.bundles');
        foreach ($bundles as $id => $class) {
            $data['bundles'][] = [$id, $id];
        }

        $data['criteria'] = [
            ['key' => 'subject_like', 'value' => 'Subject like'],
            ['key' => 'subject_not_like', 'value' => 'Subject not like'],
            ['key' => 'body_like', 'value' => 'Body Like'],
            ['key' => 'body_not_like', 'value' => 'Body not like'],
            ['key' => 'priority_is', 'value' => 'Priority is'],
            ['key' => 'priority_in', 'value' => 'Priority in'],
            ['key' => 'priority_min', 'value' => 'Priority min'],
            ['key' => 'type_is', 'value' => 'Type is'],
            ['key' => 'type_in', 'value' => 'Type in'],
            ['key' => 'channel_is', 'value' => 'Channel is'],
            ['key' => 'channel_like', 'value' => 'Channel like'],
            ['key' => 'channel_in', 'value' => 'Channel in'],
            ['key' => 'role_is', 'value' => 'Role is'],
            ['key' => 'min_age', 'value' => 'Min age'],
            ['key' => 'max_age', 'value' => 'Max age'],
            ['key' => 'start_date', 'value' => 'Start date'],
            ['key' => 'end_date', 'value' => 'End date'],
            ['key' => 'date_is', 'value' => 'Date is'],
            ['key' => '', 'value' => ''],
        ];

        return new JsonResponse($data);
    }