@param $filter

@return array
15158
private function getParamsFromFilter()
    {
        if (!$this->body['filter']) {
            return [];
        }

        $result  = [];
        $must    = [];
        $mustNot = [];

        $params = $this->body['filter']->getParams();

        if (isset($params['groupBy']) && $params['groupBy']) {
            $result = $this->initGroupBy($params['factorValues'] ?? []);
        }

        if (isset($params['factorValues']) && $params['factorValues'] && !$this->groupBy) {
            $sortEl[] = new SortElement("_script", "desc", [
                'type'   => "number",
                'script' => (new MathSumWithFactor($params['factorValues']))->getAlgorithm(),
            ]);

            $this->body['sort'] = (new SortBuilder($sortEl))->toArray()['sort'];
        }

        if (isset($params['entities']) && $params['entities']) {
            $result['index'] = $params['entities'];
        }

        if (isset($params['keyword'])) {
            $must[] = new MultiMatchQuery($params['keyword']['value'], $params['keyword']['fields']);
        }

        foreach ($params['params'] ?? [] as $param) {
            list($query, $operator) = $param->createFilter();

            if ($operator == FilterOperators::IN) {
                $must[] = $query;
            } else {
                $mustNot[] = $query;
            }
        }

        if ($mustNot || $must) {

            $query = new QueryBuilder();
            if ($mustNot) {
                $query->setMustNot(new MustNotQuery($mustNot));
            }
            if ($must) {
                $query->setMust(new MustQuery($must));
            }

            $result['body']['query'] = $query->toArray();
        }

        return $result;
    }
896280
public static function getOrders($filter = array())
    {
        $filter = Filter::create($filter);
        return self::getCollection('/orders' . $filter->toQuery(), 'Order');
    }
546569
public function find($filter)
    {
        if (is_null($this->settings)) {
            $this->settings();
        }

        return $this->settings[$filter];
    }
486615
public function getFilter($column, $filter = null)
    {
        if (null === $filter) {
            return $this->filters[$column] ?? null;
        }
        return $this->filters[$column][$filter] ?? null;
    }
677514
public function properties($filter = null)
    {
        if (is_null($filter))
        {
            $properties = $this->object->getProperties();
        }
        else
        {
            $properties = $this->object->getProperties($filter);
        }

        return array_map([$this, 'extractComment'], $properties);
    }
1147491
public function getFilter($filter) {
        if ($this->hasFilter($filter)) {
            return $this->_filters[$filter];
        }

        throw new MissingFilterException(sprintf('Filter %s does not exist', $filter));
    }
979909
public static function getOptionValues($filter = array())
    {
        $filter = Filter::create($filter);
        return self::getCollection('/options/values' . $filter->toQuery(), 'OptionValue');
    }
511569
public function all($filter)
    {
        $result = $this->toArray();

        // If the value is null return the default
        if(!empty($result))
        {
            // Handle magic quotes compatibility
            if (get_magic_quotes_gpc()) {
                $result = $this->_stripSlashes( $result );
            }

            // Filter the data
            if(!($filter instanceof FilterInterface)) {
                $filter = $this->getObject('filter.factory')->createChain($filter);
            }

            $result = $filter->sanitize($result);
        }

        return $result;
    }
1357001
protected function getFunctionariesFilter(string $filter = null)
    {
        $mappingConfiguration = new PropertyMappingConfiguration();
        $mappingConfiguration->setTypeConverter($this->typeConverterObjectConverter);
        $mappingConfiguration->setTypeConverterOption(\RGU\Dvoconnector\Property\TypeConverter\ObjectConverter::class, \RGU\Dvoconnector\Property\TypeConverter\ObjectConverter::CONFIGURATION_OBJECT, $this->getDefaultFunctionariesFilter());

        return $this->convertFunctionariesFilter($mappingConfiguration, $filter);
    }
143189
protected function getFilterResolver(string $filter): array
    {
        $class = $filter;
        $method = 'filter';

        $position = \strpos($filter, '@');

        if ($position === 0) {
            $method = 'filter'.\ucwords(\substr($filter, 1));

            return [$this, $method];
        }

        if ($position !== false) {
            list($class, $method) = \explode('@', $filter, 2);
        }

        return $this->makeFilterResolver($class, $method);
    }
591614
public function getComments($filter = null)
    {
        $comments = $this->comments;

        if ($filter !== null) {
            $comments = array_filter($comments, function ($c) use ($filter) {
                return $c['context'] == $filter;
            });
        }

        return $comments;
    }
1233555
public function getProperties($filter = \ReflectionProperty::IS_PUBLIC)
    {
        $properties = array();
        $reflectionProperties = $this->reflectionEntity->getProperties($filter);
        foreach ($reflectionProperties as $property) {
            $properties[] = new Property($property->name, $property->isStatic());
        }

        return $properties;
    }
1024937
protected function loadFilter($filter)
	{
		static $misses = [];

		if ( ! in_array($filter, $misses))
		{
			try
			{
				if ($obj = \Dependency::resolve('security.filter.'.strtolower($filter), array($this)))
				{
					$this->filters[strtolower($filter)] = $obj;

					return true;
				}
			}
			catch (\Fuel\Dependency\ResolveException $e)
			{
				// we don't have a class for this filter
				$misses[] = $filter;
			}
		}

		return false;
	}
184922
public function getProperties($filter = -1)
    {
        $properties = parent::getProperties($filter);
        foreach ($properties as $key => $val) {
            $properties[$key] = new ReflectionProperty($this->getName(), $val->getName());
        }

        return $properties;
    }
1166091
public function getServices($filter = null)
	{
		$services = array();

		// Create the request
		$request = new client\Request('/api/mpegts/service/grid');

		if ($filter)
			$request->setFilter($filter);

		// Get the response
		$response = $this->_client->getResponse($request);
		$rawContent = $response->getContent();

		$content = json_decode($rawContent);

		foreach ($content->entries as $entry)
			$services[] = model\Service::fromRawEntry($entry);

		return $services;
	}
122826
public static function filterByListLookup($filter)
    {
        $operator = Arr::get($filter, 'operator');
        $method = Arr::get($filter, 'method');
        $source = Arr::get($filter, 'settings.source');
        $arguments = Arr::get($filter, 'arguments');
        $value_one = Arr::get($filter, 'value_one');
        $value_two = Arr::get($filter, 'value_two');
        $settings = Arr::get($filter, 'settings');
        $positive = Arr::get($filter, 'positive');

        if (Arr::has($filter, 'settings.source')) {
            $model = Arr::get($filter, 'settings.model');

            $method_transform = 'transform'.Str::studly($source).'Value';

            if (method_exists($model, $method_transform)) {
                $value_one = $model->$method_transform($value_one);
            }

            $method_lookup = 'getFilter'.Str::studly($source).'Result';

            if (empty($value_one)) {
                return false;
            }

            if (method_exists($model, $method_lookup)) {
                $value_one = $model->$method_lookup($value_one);
            } else {
                throw new \Exception(sprintf('%s is missing method %s', $model->getTable(), $method_lookup));
            }

            if ($value_one === false) {
                return false;
            }

            $operator = 'IN';
            $method = 'whereIn';
            $arguments = [$value_one];
        } else {
            $value_one = [];
        }

        return [
            'operator'  => $operator,
            'method'    => $method,
            'arguments' => $arguments,
            'value_one' => $value_one,
            'value_two' => $value_two,
            'settings'  => $settings,
            'positive'  => $positive,
        ];
    }
624013
public function find($key, $filter = null) {
		if (!$this->has($key)) {
			return [];
		}
		
		$annotations = [];
		
		foreach ($this->names[$key] as $index) {
			if (!is_int($filter)) {
				$annotations[] = $this->annotations[$index];
				continue;
			}
			
			$annotation = $this->annotations[$index];
			$flags = 0;
			
			//match value type
			if ($filter & Filter::TYPE_ALL) {
				$value = $annotation->getValue();
				if (is_null($value)) {
					$flags |= Filter::TYPE_NULL;
				}
				elseif (is_string($value)) {
					$flags |= Filter::TYPE_STRING;
				}
				elseif (is_int($value)) {
					$flags |= Filter::TYPE_INTEGER;
				}
				elseif (is_float($value)) {
					$flags |= Filter::TYPE_FLOAT;
				}
				elseif (is_bool($value)) {
					$flags |= Filter::TYPE_BOOLEAN;
				}
				elseif (is_array($value)) {
					$flags |= Filter::TYPE_ARRAY;
				}
				elseif (id_object($value)) {
					$flags |= Filter::TYPE_OBJECT;
				}
			}
			
			//match argument filter
			if ($filter & Filter::HAS_ARGUMENT || $filter & Filter::NOT_HAS_ARGUMENT) {
				if ($annotation->getArgument()) {
					$flags |= Filter::HAS_ARGUMENT;
				}
				else {
					$flags |= Filter::NOT_HAS_ARGUMENT;
				}
			}
			
			//add annotation if it meets all requirements
			if (($flags & $filter) == $flags) {
				$annotations[] = $annotation;
			}
		}
		
		return $annotations;
	}