Fetch filter options from foreign table taking the given flag into account.

@param IFilter $filter The filter to which the rules shall be added to.

@return void

@SuppressWarnings(PHPMD.Superglobals)
@SuppressWarnings(PHPMD.CamelCaseVariableName)
185213
public function buildFilterRulesForFilterSetting($filter)
    {
        if (!$this->get('select_filter')) {
            return;
        }

        // Set Filter and co.
        $filterSettings = $this->filterSettingFactory->createCollection($this->get('select_filter'));

        if ($filterSettings) {
            $values       = $_GET;
            $presets      = (array) $this->get('select_filterparams');
            $presetNames  = $filterSettings->getParameters();
            $filterParams = \array_keys($filterSettings->getParameterFilterNames());
            $processed    = [];

            // We have to use all the preset values we want first.
            foreach ($presets as $presetName => $preset) {
                if (\in_array($presetName, $presetNames)) {
                    $processed[$presetName] = $preset['value'];
                }
            }

            // Now we have to use all FrontEnd filter params, that are either:
            // * not contained within the presets
            // * or are overridable.
            foreach ($filterParams as $parameter) {
                // Unknown parameter? - next please.
                if (!\array_key_exists($parameter, $values)) {
                    continue;
                }

                // Not a preset or allowed to override? - use value.
                if ((!\array_key_exists($parameter, $presets)) || $presets[$parameter]['use_get']) {
                    $processed[$parameter] = $values[$parameter];
                }
            }

            $filterSettings->addRules($filter, $processed);
        }
    }
1206265
public function afind($filter = NULL, array $options = NULL, $ttl = 0, $rel_depths = 1) {
		$result = $this->find($filter, $options, $ttl);
		return $result ? $result->castAll($rel_depths): NULL;
	}
550473
protected function parseFilterWithModel(FilterInterface $filter)
    {
        if ($this->hasModel()) {
            if ($filter->hasProperty()) {
                $model    = $this->model();
                $property = $filter->property();
                if (is_string($property) && $model->hasProperty($property)) {
                    $property = $model->property($property);

                    if ($property->l10n()) {
                        $filter->setProperty($property->l10nIdent());
                    }

                    if ($property->multiple()) {
                        $filter->setOperator('FIND_IN_SET');
                    }
                }
            }

            if ($filter instanceof FilterCollectionInterface) {
                $filter->traverseFilters(function (FilterInterface $expr) {
                    $this->parseFilterWithModel($expr);
                });
            }
        }

        return $filter;
    }
184988
public function invalidateResourceIndex(FilterInterface $filter = null)
    {
        $this->cache->deleteItem($this->getResourceIndexKey($filter));
    }
36641
private function isFilterable($filter)
    {
        if (is_string($filter) && ! class_exists($filter)) {
            throw new Exceptions\InvalidFilterException(
                "The [$filter] class does not exits."
            );
        }

        if ( ! in_array(Filterable::class, class_implements($filter))) {
            throw new Exceptions\InvalidFilterException(
                'The filter must be a Closure or a class implementing the Filterable interface.'
            );
        }
    }
663120
public function filter($id, $filter = 'all')
    {
        $allowed = array('none', 'open', 'closed', 'all');
        $filters = $this->validateAllowedParameters($allowed, $filter, 'filter');

        return $this->get($this->getPath($id).'/'.implode(',', $filters));
    }
859546
public function applyFilterSelect(Filter\FilterSelect $filter)
	{
		$this->data_source = $this->data_source->findBy([$this->prepareColumn($filter->getColumn()) => $filter->getValue()]);
	}
97314
public function addFilter(Filter $filter)
    {
        $key = $filter->getKey();
        $this->filters[$key] = $filter;
    }
249854
public function load($filter = NULL, array $options = NULL, $ttl = 0) {
		$this->reset();
		$this->_ttl=$ttl?:$this->rel_ttl;
		$res = $this->filteredFind($filter, $options, $ttl);
		if ($res) {
			$this->mapper->query = $res;
			$this->first();
		} else
			$this->mapper->reset();
		$this->emit('load');
		return $this->valid();
	}
104528
public function setFilter($filter)
    {
        parent::setFilter($filter);

        $this->userOptions['value'] = $this->validator->arrayGet($filter, 'value', '');

        //if it isn't null, we have to check the 'true'/'false' string
        if ($this->userOptions['value'] !== '') {
            $this->userOptions['value'] = $this->userOptions['value'] === 'false' || !$this->userOptions['value'] ? 0 : 1;
        }
    }
682686
function removeFilter(iFilterStream $filter)
    {
        $filterName = $filter->getLabel();
        if (isset($this->attachedFilters[$filterName])) {
            $filterRes = $this->attachedFilters[$filterName];

            stream_filter_remove($filterRes);
            unset($this->attachedFilters[$filterName]); // filter was removed
        }

        return $this;
    }
949147
public function Members($filter = '')
    {
        // First get direct members as a base result
        $result = $this->DirectMembers();

        // Unsaved group cannot have child groups because its ID is still 0.
        if (!$this->exists()) {
            return $result;
        }

        // Remove the default foreign key filter in prep for re-applying a filter containing all children groups.
        // Filters are conjunctive in DataQuery by default, so this filter would otherwise overrule any less specific
        // ones.
        if (!($result instanceof UnsavedRelationList)) {
            $result = $result->alterDataQuery(function ($query) {
                /** @var DataQuery $query */
                $query->removeFilterOn('Group_Members');
            });
        }

        // Now set all children groups as a new foreign key
        $familyIDs = $this->collateFamilyIDs();
        $result = $result->forForeignID($familyIDs);
        
        return $result->where($filter);
    }
1184107
public function visitFilter(FilterInterface $filter)
    {
        if ($filter instanceof DummyFilter) {
            $type = 'dummy';
        } elseif ($filter instanceof SelectFilter) {
            $type = 'select';
        } elseif ($filter instanceof SearchFilter) {
            $type = 'search';
        } elseif ($filter instanceof SortFilter) {
            $type = 'sort';
        } elseif ($filter instanceof PaginationFilter) {
            $type = "{$filter->getType()}-pagination";
        } elseif (method_exists($filter, 'getType') === true) {
            $type = $filter->getType();
        } else {
            $type = 'dummy';
        }
        $template = "filter/$type.twig";

        return $this
            ->loadTemplate($template)
            ->render(
                [
                    "id" => $filter->getId(),
                    "options" => $filter->getOptions(),
                ]
            );
    }
1127106
protected function filter($value, $filter)
    {
        if (null !== $filter) {
            $value = Filter::_($value, $filter);
        }

        return $value;
    }
952642
private static function fixFilterFieldPath(?Filter $filter): ? Filter
    {
        if (is_null($filter)) {
            return $filter;
        }

        $filterAsArray = $filter->toArray();
        $filterAsArray['field'] = Item::getPathByField($filterAsArray['field']);

        return Filter::createFromArray($filterAsArray);
    }
1368110
private function addFilter($filter)
    {
        if (is_array($filter)) {
            if (!isset($filter['method'])) {
                throw new \InvalidArgumentException(
                    'A [method] value must be specified for each complex filter'
                );
            }
        }

        if (!$this->filters) {
            $this->filters = [$filter];
        } else {
            $this->filters[] = $filter;
        }

        return $this;
    }
546569
public function find($filter)
    {
        if (is_null($this->settings)) {
            $this->settings();
        }

        return $this->settings[$filter];
    }