Return database query condition from filter data

@param string $plugin Name of plugin for target model of filter.
@return array Return database query condition from filter data.
967928
public function getFilterConditions($plugin = null) {
		$filterData = null;
		$filterCond = null;
		if ($this->_controller->request->is('get')) {
			$filterData = $this->_controller->request->query('data.FilterData');
			$filterCond = $this->_controller->request->query('data.FilterCond');
		} elseif ($this->_controller->request->is('post')) {
			$filterData = $this->_controller->request->data('FilterData');
			$filterCond = $this->_controller->request->data('FilterCond');
		}
		$conditions = $this->_modelFilter->buildConditions($filterData, $filterCond, $plugin);

		return $conditions;
	}
260102
public function select($name = null, $default = null)
    {
        if (!$this->db->isInitialized()) {
            return isset($name) ? $default : array();
        }

        $conditions = array();

        $sql = 'SELECT * FROM settings';

        if (isset($name)) {
            $conditions[] = $name;
            $sql .= ' WHERE id=? LIMIT 0,1';
        }

        $settings = array();

        foreach ($this->db->fetchAll($sql, $conditions) as $result) {

            if (!empty($result['serialized'])) {
                $result['value'] = unserialize($result['value']);
            }

            $settings[$result['id']] = $result['value'];
        }

        return isset($name) ? reset($settings) : $settings;
    }
425658
public function getPluginPrompts( $plugin ) {
		$pluginPrompts = array();

		$prompts = $this->getPrompts();

		foreach ( $prompts as $prompt ) {
			if ( $prompt['plugin'] === $plugin ) {
				$pluginPrompts[] = $prompt;
			}
		}

		return $pluginPrompts;
	}
770983
public function getFilter(string $fieldName): ?Condition
    {
        [$name, $filters] = $this->getArrayAndKeyName($fieldName, 'filters');

        return array_first($filters, function ($filter) use ($name) {
            return $filter->getName() === $name;
        });
    }
422014
private function getPaths($plugin): array
    {
        if ($plugin === null || !Plugin::loaded($plugin)) {
            return App::path('Template');
        }

        return App::path('Template', $plugin);
    }
44494
protected function parseCondition($condition)
    {
        $tableAlias = $this->getAlias();
        $parts = [];

        if ($condition instanceof QueryBuilderAwareInterface) {
            $condition->setQueryBuilder($this);
        }

        if ($condition instanceof Expression) {
            $parts[] = $this->getAdapter()->quoteSql($condition->toSQL());
        } elseif ($condition instanceof Q) {
            $condition->setLookupBuilder($this->getLookupBuilder());
            $condition->setAdapter($this->getAdapter());
            $condition->setTableAlias($tableAlias);
            $parts[] = $condition->toSQL();
        } elseif ($condition instanceof ToSqlInterface) {
            $parts[] = $condition->toSQL();
        } elseif (is_array($condition)) {
            foreach ($condition as $key => $value) {
                if ($value instanceof Q) {
                    $parts[] = $this->parseCondition($value);
                } else {
                    list($lookup, $column, $lookupValue) = $this->lookupBuilder->parseLookup($this, $key, $value);
                    $column = $this->getLookupBuilder()->fetchColumnName($column);
                    if (false === empty($tableAlias) && false === strpos($column, '.')) {
                        $column = $tableAlias.'.'.$column;
                    }
                    $parts[] = $this->lookupBuilder->runLookup($this->getAdapter(), $lookup, $column, $lookupValue);
                }
            }
        } elseif (is_string($condition)) {
            $parts[] = $condition;
        } elseif ($condition instanceof Expression) {
            $parts[] = $condition->toSQL();
        }

        if (1 === count($parts)) {
            return $parts[0];
        }

        return '('.implode(') AND (', $parts).')';
    }
718102
protected static function getMethods($plugin)
    {
        //Sets the class name
        $class = App::classname($plugin . '.Sitemap', 'Utility');

        //Gets all methods from the `Sitemap` class of the plugin
        $methods = get_child_methods($class);

        if (empty($methods)) {
            return [];
        }

        return collection($methods)->map(function ($method) use ($class) {
            return array_merge(compact('class'), ['name' => $method]);
        })->toList();
    }
379050
public function condition($inputs)
    {
        if (!array_has($inputs, $this->column)) {
            return;
        }

        $this->value = array_get($inputs, $this->column);

        $value = array_filter($this->value, function ($val) {
            return '' !== $val;
        });

        if (empty($value)) {
            return;
        }

        if (!isset($value['start'])) {
            return $this->buildCondition($this->column, '<=', $value['end']);
        }

        if (!isset($value['end'])) {
            return $this->buildCondition($this->column, '>=', $value['start']);
        }

        $this->query = 'whereBetween';

        return $this->buildCondition($this->column, $this->value);
    }
574
public function findWhere($conditions=null, $_=null)
    {
        $query =  $this->db->select($this->getColumns())
            ->from($this->entity->getTable());
        $query->context->resultHandler = function ($result){
            foreach ($result as &$i){
                $i = $this->entity->make($i, false);
            }
            return $result;
        };
        return call_user_func_array([$query, 'where'], func_get_args());
    }
726722
public function getRequiredBy($plugin)
    {
        $requiredBy = [];
        $plugin = $this->getBundle($plugin);

        foreach ($this->getInstalledBundles() as $bundle) {
            $requirements = $bundle['instance']->getRequiredPlugins();
            if (in_array(get_class($plugin), $requirements)) {
                $requiredBy[] = get_class($bundle['instance']);
            }
        }

        return $requiredBy;
    }
1079113
public function search($params)
    {
        $query = Event::find()->with('category');

        $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,
            'plugin_id' => $this->plugin_id,
            'app_id' => $this->app_id,
            'category_id' => $this->category_id,
            'status' => $this->status
        ]);

        $query->andFilterWhere(['like', 'trigger_class', $this->trigger_class])
            ->andFilterWhere(['like', 'trigger_event', $this->trigger_event])
            ->andFilterWhere(['like', 'handler_class', $this->handler_class])
            ->andFilterWhere(['like', 'handler_method', $this->handler_method])
            ->andFilterWhere(['like', 'data', $this->data]);

        return $dataProvider;
    }
1373099
public function search($params)
    {
        $query = Type::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,
            'parent' => $this->parent,
        ]);

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

        return $dataProvider;
    }
77669
private function getConditionSelectQuery(): QueryBuilder
    {
        $query = $this->connection->createQueryBuilder();
        $query->select('DISTINCT ngbm_rule_condition.*')
            ->from('ngbm_rule_condition');

        return $query;
    }
341297
public function filter( $condition ) {
		$storage = array();

		foreach ( $this->storage as $key => $value ) {
			if ( call_user_func( $condition, $value, $key ) ) {
				$storage[ $key ] = $value;
			}
		}

		return new static( $this->get_key_type(), $this->get_value_type(), $storage );
	}
898950
public function find(SQLPredicate $condition = null) {
		$this->mapper->connect();
		$table = $this->entityProfile->getEntityTable();
		
		//build fluent query
		$query = $this->mapper->newQuery($this->entityProfile)
		->from($table, Schema::DEFAULT_ALIAS)
		->select($this->getSelectColumns());
		
		//set query condition
		$args = func_get_args();
		if (empty($args) && $this->hasOption('query.filter'))
			$query->where($this->getFilter());
		elseif (isset($condition))
			$query->where(new Filter($args));
		
		//order by
		if ($this->hasOption('query.orderBy'))
			$query->orderBy($this->getOrderBy());
		
		//limit + offset
		if ($this->hasOption('query.limit'))
			$query->limit($this->getOption('query.limit'));
		
		if ($this->hasOption('query.offset'))
			$query->offset($this->getOption('query.offset'));
		
		//distinct
		if ($this->hasOption('query.distinct') && $this->getOption('query.distinct'))
			$query->distinct();
		
		list($sql, $args) = $query->build();
		return $this->mapper->merge($this->clean(['map.type' => $this->getListMappingExpression()]))->execute($sql, $args);
	}
670764
public function getListByProperties($condition = NULL, $value = NULL) {
    $options = [];
    foreach ($this->getDefinitions() as $plugin_id => $plugin_definition) {
      if (empty($condition) || (isset($plugin_definition[$condition]) && $plugin_definition[$condition] === $value)) {
        $options[] = $plugin_id;
      }
    }
    return $options;

  }
677461
protected function getFilterQuery($locale)
    {
        $qb = $this->createQueryBuilder('filter')
            ->addSelect('conditionGroups')
            ->addSelect('translations')
            ->addSelect('conditions')
            ->leftJoin(
                'filter.translations',
                'translations',
                'WITH',
                'translations.locale = :locale'
            )
            ->leftJoin('filter.conditionGroups', 'conditionGroups')
            ->leftJoin('conditionGroups.conditions', 'conditions')
            ->setParameter('locale', $locale);

        return $qb;
    }