{@inheritdoc}

@see \Concrete\Core\Search\Field\FieldInterface::filterList()
777226
public function filterList(ItemList $list)
    {
        $localeID = $this->data['localeID'];
        $app = Facade::getFacadeApplication();
        if (isset($this->data['localeID']) && $this->data['localeID'] !== '') {
            $em = $app->make(EntityManager::class);
            $selectedLocale = $em->find(Locale::class, $this->data['localeID']);
            $list->setSiteTreeObject($selectedLocale->getSiteTree());
        }
    }
1155208
public function filter($fieldMap = array())
    {
        if (empty($this->filter['filters'])) {
            return array();
        }

        $where = new Predicate();
        $where->addPredicate($this->parseFilters($this->filter, $fieldMap));

        return $where;
    }
288669
public function filter($value)
    {
        /** @var InputFilterInterface $filter */
        foreach ($this->filters as $filter) {
            if (true === is_array($value)) {
                $values = array();
                foreach ($value as $child) {
                    if (null !== $filtered = $filter->filter($child)) {
                        $values[] = $filtered;
                    }
                }
                $value = $values;
            } else {
                $value = $filter->filter($value);
            }
        }

        return $value;
    }
146205
public function addAllFilters()
    {
        $fields = array_keys($this->getDataObjectInstance()->searchableFields());
        foreach ($fields as $fieldName) {
            $this->addDefaultFilters($fieldName);
        }

        return $this;
    }
753520
public static function filterListData($objectData, $filters = array())
    {
        $result = array();
        foreach ($objectData as $fieldData) {
            $filteredItems = array();
            //====================================================================//
            // Ensure Item is An Array of Fields
            if (!is_array($fieldData) && !($fieldData instanceof ArrayObject)) {
                continue;
            }
            //====================================================================//
            // Convert ArrayObjects to Array
            if ($fieldData instanceof ArrayObject) {
                $fieldData = $fieldData->getArrayCopy();
            }
            //====================================================================//
            // Search for Field in Item Block
            foreach ($filters as $fieldId) {
                if (array_key_exists($fieldId, $fieldData)) {
                    $filteredItems[$fieldId] = $fieldData[$fieldId];
                }
            }
            $result[] = $filteredItems;
        }

        return $result;
    }
950233
protected function queryList()
    {
        // Sanity check
        $dataClass = $this->dataRecord->getDataClass();
        if (!$dataClass) {
            return ArrayList::create();
        }

        // Setup
        $singleton = $this->dataRecord->getDataSingleton();

        // Create list
        $list = $singleton->get();

        // Setup filters
        $filters = [];
        foreach ($singleton->config()->get('searchable_fields') as $field) {
            $value = $this->getRequest()->getVar(str_replace('.', '_', $field));
            if (!$value) {
                continue;
            }

            // if the searchable field is a relationship, it must be an exact match (ID match) if not partial is fine.
            $matchType = $this->instanceHasRelationship($singleton, $field) ? "ExactMatch" : "PartialMatch";
            $filters[$field . ':' . $matchType] = $value;
        }
        $list = $list->filter($filters);

        // Sort
        $sort = $this->getRequest()->getVar('Sort');
        if ($sort) {
            $dir = 'ASC';
            if ($this->getRequest()->getVar('Dir')) {
                $dir = $this->getRequest()->getVar('Dir');
            }
            $list = $list->sort($sort, $dir);
        }

        return $list;
    }
67000
private static function filterInList($operation, &$params)
    {
        $params    = \array_merge($params, \array_values($operation['values']));
        $wildcards = \rtrim(\str_repeat('?,', \count($operation['values'])), ',');

        return \sprintf('(%s IN (%s))', $operation['property'], $wildcards);
    }
239394
public function filter()
    {
        $condition = func_get_args();
        $cName = Utility::get($condition, 0);
        if (gettype($cName)=="object" && is_callable($cName)) {
            //Able to filter by function
            return $this->filterByFunc($cName);
        }
        $operator = Utility::get($condition, 1);
        $value = Utility::get($condition, 2);
        $optional_value = Utility::get($condition, 3);

        if ($cName===null||$operator===null) {
            throw new \Exception('dataStore->filter() requires condition in array form ($colname,$operator,$value)');
        }

        $result = array();
        $cType = $this->metaData["columns"][$cName]["type"];
        $dtFormat = null;
        if (in_array($cType, array("datetime", "date", "time"))) {
            switch ($cType)
            {
            case "datetime":
                $dtFormat = Utility::get($this->metaData["columns"][$cName], "format", "Y-m-d H:i:s");
                break;
            case "date":
                $dtFormat = Utility::get($this->metaData["columns"][$cName], "format", "Y-m-d");
                break;
            case "time":
                $dtFormat = Utility::get($this->metaData["columns"][$cName], "format", "H:i:s");
                break;
            }
            $value =  \DateTime::createFromFormat($dtFormat, $value);
        }
        
        foreach ($this->rows as $row) {
            $columnValue = $row[$cName]; 
            if ($dtFormat!==null) {
                $columnValue =  \DateTime::createFromFormat($dtFormat, $columnValue);
            }
            switch($operator)
            {
            case "=":
            case "==":
            case "equal":
                if ($columnValue==$value) {
                    array_push($result, $row);
                }
                break;
            case "===":
                if ($columnValue===$value) {
                    array_push($result, $row);
                }
                break;
            case "!=":
            case "notEqual":
                if ($columnValue!=$value) {
                    array_push($result, $row);
                }
                break;
            case "!==":
                if ($columnValue!==$value) {
                    array_push($result, $row);
                }
                break;
            case ">":
            case "gt":
                if ($columnValue>$value) {
                    array_push($result, $row);
                }
                break;
            case ">=":
                if ($columnValue>=$value) {
                    array_push($result, $row);
                }
                break;
            case "<":
            case "lt":
                if ($columnValue<$value) {
                    array_push($result, $row);
                }
                break;
            case "<=":
                if ($columnValue<=$value) {
                    array_push($result, $row);
                }
                break;
            case "contain":
            case "contains":
                if (strpos(strtolower($columnValue), strtolower($value))!==false) {
                    array_push($result, $row);
                }
                break;
            case "notContain":
            case "notContains":
                if (strpos(strtolower($columnValue), strtolower($value))===false) {
                    array_push($result, $row);
                }
                break;
            case "between":
                if ($value<$columnValue && $columnValue<$optional_value) {
                    array_push($result, $row);
                }
                break;
            case "notBetween":
                if (!($value<$columnValue && $columnValue<$optional_value)) {
                    array_push($result, $row);
                }
                break;
            case "in":
                if (!is_array($value)) {
                    $value = array($value);
                }
                if (in_array($columnValue, $value)) {
                    array_push($result, $row);
                }
                break;
            case "notIn":
                if (!is_array($value)) {
                    $value = array($value);
                }
                if (!in_array($columnValue, $value)) {
                    array_push($result, $row);
                }
                break;
            case "startWith":
            case "startsWith":
                if (strpos(strtolower($columnValue), strtolower($value)) === 0) {
                    array_push($result, $row);
                }
                break;
            case "notStartWith":
            case "notStartsWith":
                if (strpos(strtolower($columnValue), strtolower($value)) !== 0) {
                    array_push($result, $row);
                }
                break;
            case "endWith":
            case "endsWith":
                if (strpos(strrev(strtolower($columnValue)), strrev(strtolower($value))) === 0) {
                    array_push($result, $row);
                }
                break;
            case "notEndWith":
            case "notEndsWith":
                if (strpos(strrev(strtolower($columnValue)), strrev(strtolower($value))) !== 0) {
                    array_push($result, $row);
                }
                break;
            default:
                throw new \Exception("Unknown operator [$operator]");
                return $this;
                break;
            }
        }
        return new DataStore($result, $this->metaData);
    }
776353
public function filterNe(string $field, $value): self
    {
        $this->filters[] = new IndexQueryFilter($field, IndexQueryFilterOperator::NOT_EQUAL_TO(), $value);
        return $this;
    }
698444
public function filterList(ItemList $list)
    {
        if ($this->association !== null && $this->getSelectedEntry()) {
            $list->filterByAssociatedEntry($this->association, $this->getSelectedEntry());
        }
    }
439579
protected function getListFieldValue()
    {
        $conditions = $this->query_filter;
        $conditions['limit'] = $this->data_limit;
        $conditions['field_id'] = $this->data_field['field_id'];

        $list = (array) $this->field_value->getList($conditions);
        $this->prepareListFieldValue($list);
        return $list;
    }
940521
protected function filterList($list)
    {
        $conf = Configuration::getConfig(self::CONFIG_FILE_NAME);
        $disableWhitelisting
            = $conf->getBoolean(self::PROPNAME_DISABLE_WHITELISTING, false);

        if (!isset($this->originalsp['disco.doNotFilterIdps'])
            || !$this->originalsp['disco.doNotFilterIdps']
        ) {
            $list = parent::filterList($list);
            $list = $this->scoping($list);
            if (!$disableWhitelisting) {
                $list = $this->whitelisting($list);
            }
            $list = $this->greylisting($list);
            $list = $this->greylistingPerSP($list, $this->originalsp);
        }

        if (empty($list)) {
            throw new Exception('All IdPs has been filtered out. And no one left.');
        }

        return $list;
    }
1342945
public function fieldFilter(QueryBuilder $queryBuilder, FieldInterface $field, $value)
    {
        if ($value) {
            $name = $field->getName();
            $path = $field->getOption('association_path');

            /**
             * Handle array or collections of items
             */
            if (is_array($value) || $value instanceof \Traversable) {

                $expr = $queryBuilder->expr()->orX();
                foreach ($value as $index => $v) {
                    $param = 'filter_' . $name . '_' . $index;
                    $queryBuilder->setParameter($param, $v);

                    if (is_object($v)) {
                        $expr->add(":$param MEMBER OF $path");
                    } else {
                        $expr->add("$path = :$param");
                    }
                }

                $queryBuilder->andWhere($expr);
            } else {
                /**
                 * Single value filter.
                 */
                $operator = $field->getOption('filter_operator');
                $comparison = new Query\Expr\Comparison($path, $operator, ':filter_' . $name);

                // Fix LIKE operators value (append and prepend %)
                // todo : parameterize this ?
                if ($operator == 'LIKE' || $operator == 'NOT LIKE') {
                    $value = '%' . $value . '%';
                }

                $queryBuilder
                    ->andWhere($comparison)
                    ->setParameter('filter_' . $name, $value)
                ;
            }
        }
    }
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);
        }
        );
    }
189617
protected static function filter($field)
    {
        $field = preg_replace('/[\.\/\\:;,?$*!#_-]/', '', $field);
        $field = preg_replace('/\s+/', ' ', trim($field));
        return $field;
    }
510300
public function getFiltered($page, $numRows, $sortAttr, $sortOrder, $searchAttr, $searchValue, $richFilters = [])
    {
        $query = $this->prepareQuery();

        $query = $this->richFiltersOnQuery($query, $richFilters);

        if ($sortAttr && $sortOrder && $this->inScope($sortAttr)) {
            $scope = $this->getScope($sortAttr);
            $query = $query->orderBy($scope, $sortOrder);
        }

        if ($searchAttr && $searchValue && $this->inScope($searchAttr)) {
            $scope = $this->getScope($searchAttr);
            $query = $query->where($scope, 'like', '%' . $searchValue . '%');
        }

        $collection = $query->get();

        $collection = $this->addPermissions($collection);

        $collection = $this->formatCollection($collection);

        $collection = $collection->each(function ($model) {
            $model = $this->formatModel($model);
        });

        if ($sortAttr && $sortOrder && ! $this->inScope($sortAttr)) {
            $collection = $sortOrder == 'asc'
                ? $collection->sortBy($sortAttr)
                : $collection->sortByDesc($sortAttr);
        }

        $collection = $this->richFiltersOnCollection($collection, $richFilters);

        if ($searchAttr && $searchValue && ! $this->inScope($searchAttr)) {
            $collection = $collection->filter(function ($model) use ($searchAttr, $searchValue) {
                $value = (string) $model->$searchAttr;
                $value = strtolower($value);
                $search = strtolower($searchValue);
                return strpos($value, $search) !== false;
            });
        }

        if ($page && $numRows) {
            $toSkip = ($page - 1) * $numRows;
            $count = $collection->count();
            $collection = $collection->take(- ($count - $toSkip))->take($numRows);
        } else if ($numRows)
            $collection = $collection->take($numRows);

        return collect(array_values($collection->toArray()));
    }
173186
public function addFilterBy(string $field, string $value): self
    {
        $this->filterBy[$field] = $value;

        return $this;
    }