@param      $filter
@param null $params
@param null $ss_filters

@return array|mixed
@throws InternalServerErrorException
15335
protected static function buildCriteriaArray($filter, $params = null, $ss_filters = null)
    {
        // interpret any parameter values as lookups
        $params = static::interpretRecordValues($params);
        // or as Mongo objects
        $params = static::toMongoObjects($params);

        // build filter array if necessary
        if (!is_array($filter)) {
            Session::replaceLookups($filter);
            $test = json_decode($filter, true);
            if (!is_null($test)) {
                // original filter was a json string, use it as array
                $filter = $test;
            }
        }
        $criteria = static::buildFilterArray($filter, $params);

        // add server-side filters if necessary
        $serverCriteria = static::buildSSFilterArray($ss_filters);
        if (!empty($serverCriteria)) {
            $criteria = (!empty($criteria)) ? ['$and' => [$criteria, $serverCriteria]] : $serverCriteria;
        }

        return $criteria;
    }
49453
public function withFilter(Filter $filter)
    {
        if ($this->value->isNull()) {
            return null;
        }

        return $this->applyFilter($filter);
    }
327367
protected function _params_filter($parameters = array()){
    $params = array();
    foreach($parameters as $key => $val) {
        if ($key == "Signature" ||$val === "" || $val === NULL){
          continue;
        } else {
          $params[$key] = $parameters[$key];
        }
    }
    ksort($params);
    reset($params);
    return $params;
  }
599761
private function initFilters(array $filters)
    {
    	$result = array();
    
    	$fm = $this->getFilterManager();
    
    	foreach ($filters as $alias => $options) {
    		$option = null;
    		if (is_array($options)) {
    			if (!isset($options['name'])) {
    				throw new Exception\InvalidArgumentException(
    						'Filter "' . $alias . '" required option "name"'
    				);
    			}
    
    			$name = $options['name'];
    			$option = isset($options['option']) ? $options['option'] : null;
    		} elseif (is_string($options)) {
    			$name = $options;
    			unset($options);
    		}
    
    		if (is_numeric($alias)) {
    			$alias = $name;
    		}
    
    		// Filter Id should have optional filter indicator "?"
    		$filterId = ltrim($alias, '?');
    
    		if (!$fm->has($filterId)) {
    			if (is_array($option) && !empty($option)) {
    				$r = new \ReflectionClass($name);
    				$filter = $r->newInstanceArgs($option);
    			} else if ($option) {
    				$filter = new $name($option);
    			} else {
    				$filter = new $name();
    			}
    
    			$fm->set($filterId, $filter);
    		}
    
    		$result[] = $alias;
    	}
    
    	return $result;
    }
697667
public function getAll($filter = null)
    {
        $filters = array('all', 'sales', 'purchase', 'inactive');
        if (!in_array($filter, $filters)) {
            $message = 'Unknown filter "' . $filter . '" for TaxRates';
            $message .= '; available filters: ' . implode(', ', $filters);
            throw new InvalidFilterException($message);
        }

        $rates = new ArrayObject;
        foreach ($this->connector->getAll(__NAMESPACE__) as $rate) {
            if (($filter == 'inactive' && $rate->active) || ($filter != 'inactive' && !$rate->active)) {
                continue;
            }
            if ($filter == 'sales' && $rate->taxRateType != TaxRate::RATE_TYPE_SALES) {
                continue;
            } elseif ($filter == 'purchase' && $rate->taxRateType != TaxRate::RATE_TYPE_PURCHASE) {
                continue;
            }
            $rates->append($rate);
        }
        return $rates;
    }
365006
public function getFilter($filter)
    {
        $result = null;

        if(isset($this->__filters[$filter])) {
            $result = $this->__filters[$filter];
         }

        return $result;
    }
500263
public function withFilters(array $filters = null)
    {
        if ($filters) {
            foreach ($filters as $filter) {
                switch ($filter['type']) {
                    case 'select':
                        $this->select($filter['fields']);
                        break;
                    case 'andWhere':
                        $this->andWhere($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'orWhere':
                        $this->orWhere($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'andHaving':
                        $this->andHaving($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'orHaving':
                        $this->orHaving($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'addGroupBy':
                        $this->addGroupBy($filter['field']);
                        break;
                    case 'addOrderBy':
                        $this->addOrderBy($filter['field'], $filter['order']);
                        break;
                    case 'fkAddOrderBy':
                        $this->fkAddOrderBy($filter['field'], $filter['fkField'], $filter['order']);
                        break;
                    case 'paginate':
                        if (isset($filter['page'])) {
                            $this->paginate($filter['limit'], $filter['page']);
                        } else {
                            $this->paginate($filter['limit']);
                        }
                        break;
                }
            }
        }

        return $this;
    }
26866
public function getRawTokenAnswerRows($filter = array())
    {
        $source = $this->getSource();
        return $source->getRawTokenAnswerRows((array) $filter, $this->_surveyId, $this->_gemsSurvey['gsu_surveyor_id']);
    }
822990
public function process(Aoe_ExtendedFilter_Model_Interface $filter, array $params)
    {
        // Re-parse the third parameter with the parameter tokenizer and discard original parameters
        $params = $filter->getIncludeParameters($params[2]);

        // Grab the store
        $storeId = $filter->getStoreId();

        // Pull out expected parameters
        $path = (isset($params['path']) ? $params['path'] : '');
        $modifiers = (isset($params['modifiers']) ? $params['modifiers'] : '');

        // Lookup config
        $value = '';
        if (!empty($path)) {
            $value = Mage::getStoreConfig($path, $storeId);
        }

        // If we have modifiers, process now
        if (!empty($modifiers)) {
            $value = $filter->amplifyModifiers($value, $modifiers);
        }

        return $value;
    }
836070
protected function getUserFunctionariesFilter(string $filter = null)
    {
        $mappingConfiguration = new PropertyMappingConfiguration();
        return $this->convertFunctionariesFilter($mappingConfiguration, $filter);
    }
626488
public function getOptions($filters = null)
    {
        if (!$filters) {
            return $this->_parameters;
        }

        $result = [];

        foreach ($this->_parameters as $param) {
            $result[] = $this->filter($param, $filters);
        }

        return $result;
    }
979438
public function getIterator(IteratorFilter $filter = null)
    {
        if (is_null($filter)) {
            $filter = new IteratorFilter();
        }

        $param = [];
        $formatter = new IteratorFilterSqlFormatter();
        $sql = $formatter->getFilter($filter->getRawFilters(), $param);

        $query = Query::getInstance()
            ->table($this->getUserDefinition()->table())
            ->where($sql, $param);

        return $this->userRepository->getByQuery($query);
    }
413827
private function getParamsFromFilter(FilterBuilder $filter)
    {
        $result  = [];
        $must    = [];
        $mustNot = [];

        $params = $filter->getParams();

        if ($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['query'] = $query->toArray();
        }

        return $result;
    }
19271
protected static function parseFilter($filter, $params = [])
    {
        if (empty($filter)) {
            return '';
        }

        if (is_array($filter)) {
            return ''; // todo need to build from array of parts
        }

        // handle logical operators first
        // supported logical operators are or, and, not
        $search = [' || ', ' && ', ' OR ', ' AND ', ' NOR ', ' NOT '];
        $replace = [' or ', ' and ', ' or ', ' and ', ' nor ', ' not '];
        $filter = trim(str_ireplace($search, $replace, ' ' . $filter)); // space added for 'not' case

        // the rest should be comparison operators
        // supported comparison operators are eq, ne, gt, ge, lt, le
        $search =
            ['!=', '>=', '<=', '>', '<', '=', ' EQ ', ' NE ', ' LT ', ' LTE ', ' LE ', ' GT ', ' GTE', ' GE '];
        $replace = [
            ' ne ',
            ' ge ',
            ' le ',
            ' gt ',
            ' lt ',
            ' eq ',
            ' eq ',
            ' ne ',
            ' lt ',
            ' le ',
            ' le ',
            ' gt ',
            ' ge ',
            ' ge '
        ];
        $filter = trim(str_ireplace($search, $replace, $filter));

//			WHERE name LIKE "%Joe%"	not supported
//			WHERE name LIKE "%Joe"	not supported
//			WHERE name LIKE "Joe%"	name ge 'Joe' and name lt 'Jof';
//			if ( ( '%' == $val[ strlen( $val ) - 1 ] ) &&
//				 ( '%' != $val[0] ) )
//			{
//			}

        if (!empty($params)) {
            foreach ($params as $name => $value) {
                $filter = str_replace($name, $value, $filter);
            }
        }

        return $filter;
    }
1134431
public function getMethods($filter = null)
    {
        $methods    = parent::getMethods();
        $moufMethods = array();
        foreach ($methods as $method) {
            $moufMethods[] = new MoufReflectionMethod($this, $method->getName());
        }
        
        return $moufMethods;
    }
137566
public function getStreams($filter = null)
	{
		if ($filter !== null)
		{
			if ( ! is_callable($filter))
			{
				$filter = function (StreamInterface $stream) use ($filter) {
					return (bool) ($filter & $stream->getType());
				};
			}
			
			$streams = clone $this->streams;
			
			foreach ($streams as $index => $stream)
			{
				if ($filter($stream) === false)
				{
					$streams->offsetUnset($index);
				}
			}
			
			return $streams;
		}
		
		return $this->streams;
	}
1371452
protected function getQueryFilter($params)
    {
        if (empty($params['FilterClass'])) {
            return null;
        }
        $filterClass = $params['FilterClass'];
        if (!is_subclass_of($filterClass, CMSSiteTreeFilter::class)) {
            throw new InvalidArgumentException("Invalid filter class passed: {$filterClass}");
        }
        return $filterClass::create($params);
    }