Adds relation to filter.

@param Definition $definition
@param array      $filter
@param string     $urlType
@param string     $relationType
491865
private function addRelation(Definition $definition, $filter, $urlType, $relationType)
    {
        if (empty($filter['relations'][$urlType][$relationType])) {
            return;
        }

        $relation = new Definition(
            sprintf('ONGR\FilterManagerBundle\Relation\%sRelation', ucfirst($relationType)),
            [$filter['relations'][$urlType][$relationType]]
        );
        $definition->addMethodCall(
            'set' . ucfirst($urlType) . 'Relation',
            [$relation]
        );
    }
808282
public function countRel($key, $alias=null, $filter=null, $option=null) {
		if (!$alias)
			$alias = 'count_'.$key;
		$filter_bak = null;
		if ($filter || $option) {
			$filter_bak = isset($this->relFilter[$key]) ? $this->relFilter[$key] : false;
			$this->filter($key,$filter,$option);
		}
		if (isset($this->fieldConf[$key])){
			// one-to-one, one-to-many
			if ($this->fieldConf[$key]['relType'] == 'belongs-to-one') {
				if ($this->dbsType == 'sql') {
					$this->mapper->set($alias,'count('.$this->db->quotekey($key).')');
					$this->grp_stack=(!$this->grp_stack)?$key:$this->grp_stack.','.$key;
					if ($this->whitelist && !in_array($alias,$this->whitelist))
						$this->whitelist[] = $alias;
				} elseif ($this->dbsType == 'mongo')
					$this->_mongo_addGroup(array(
						'keys'=>array($key=>1),
						'reduce' => 'prev.'.$alias.'++;',
						"initial" => array($alias => 0)
					));
				else
					trigger_error('Cannot add direct relational counter.',E_USER_ERROR);
			} elseif($this->fieldConf[$key]['relType'] == 'has-many') {
				$relConf=$this->fieldConf[$key]['has-many'];
				if ($relConf['hasRel']=='has-many') {
					// many-to-many
					if ($this->dbsType == 'sql') {
						$mmTable = $this->mmTable($relConf,$key);
						$filter = array($mmTable.'.'.$relConf['relField']
							.' = '.$this->table.'.'.$this->primary);
						$from = $this->db->quotekey($mmTable);
						if (array_key_exists($key, $this->relFilter) &&
							!empty($this->relFilter[$key][0])) {
							$options=array();
							$from = $this->db->quotekey($mmTable).' '.
								$this->_sql_left_join($key,$mmTable,$relConf['relPK'],$relConf['relTable']);
							$relFilter = $this->relFilter[$key];
							$this->_sql_mergeRelCondition($relFilter,$relConf['relTable'],
								$filter,$options);
						}
						$filter = $this->queryParser->prepareFilter($filter,
							$this->dbsType, $this->db, $this->fieldConf);
						$crit = array_shift($filter);
						if (count($filter)>0)
							$this->preBinds=array_merge($this->preBinds,$filter);
						$this->mapper->set($alias,
							'(select count('.$this->db->quotekey($mmTable.'.'.$relConf['relField']).')'.
							' from '.$from.' where '.$crit.
							' group by '.$this->db->quotekey($mmTable.'.'.$relConf['relField']).')');
						if ($this->whitelist && !in_array($alias,$this->whitelist))
							$this->whitelist[] = $alias;
					} else {
						// count rel
						$this->countFields[]=$key;
					}
				} elseif($this->fieldConf[$key]['has-many']['hasRel']=='belongs-to-one') {
					// many-to-one
					if ($this->dbsType == 'sql') {
						$fConf=$relConf[0]::resolveConfiguration();
						$fTable=$fConf['table'];
						$fAlias=$fTable.'__count';
						$rKey=$relConf[1];
						$crit = $fAlias.'.'.$rKey.' = '.$this->table.'.'.$relConf['relField'];
						$filter = $this->mergeWithRelFilter($key,array($crit));
						$filter[0] = $this->queryParser->sql_prependTableToFields($filter[0],$fAlias);
						$filter = $this->queryParser->prepareFilter($filter,
							$this->dbsType, $this->db, $this->fieldConf);
						$crit = array_shift($filter);
						if (count($filter)>0)
							$this->preBinds=array_merge($this->preBinds,$filter);
						$this->mapper->set($alias,
							'(select count('.$this->db->quotekey($fAlias.'.'.$fConf['primary']).') from '.
							$this->db->quotekey($fTable).' AS '.$this->db->quotekey($fAlias).' where '.
							$crit.' group by '.$this->db->quotekey($fAlias.'.'.$rKey).')');
						if ($this->whitelist && !in_array($alias,$this->whitelist))
							$this->whitelist[] = $alias;
					} else {
						// count rel
						$this->countFields[]=$key;
					}
				}
			}
		}
		if ($filter_bak!==null) {
			if ($filter_bak)
				$this->relFilter[$key] = $filter_bak;
			else
				$this->clearFilter($key);
		}
	}
1180644
public function addFilter($filter)
    {
        // Resolve filter object from string/object or throw Ex.
        $filterObj = FilterResolver::instance($filter);

        // If filtersOverride is allowed we will override filter
        // with same alias/name if there is one with new resolved filter.
        if ($this->getFiltersOverride()) {
            if ($key = array_search($filterObj->getName(), $this->getFilters())) {
                $this->filters[$key] = $filterObj;
            } else {
                $this->filters[$filterObj->getName()] = $filterObj;
            }
        } else {
            // If filtersOverride is disabled and we found
            // equal alias defined we will throw Ex.
            if (array_key_exists($filterObj->getName(), $this->getFilters())) {
                $ex = new FilterAlreadyBindedException($filterObj->getName(), $this->getName());
                throw $ex;
            }

            // Filter with resolvedFilter alias/name doesn't exist
            // so we will bind it as new one to field.
            $this->filters[$filterObj->getName()] = $filterObj;
        }

        return $this;
    }
1175096
public function createRelations($definition = null)
    {
        $actions = array();
        $transitions = new ArrayObject();
        $sort = 1;
        foreach ($this->structure as $relationName => $relationTemplate) {
            $isAction = isset($relationTemplate['type']);
            $isUsers = ($relationName == 'users');
            $isGroups = ($relationName == 'groups');

            // Process actions on WorkflowDefinition from the template
            if ($isAction) {
                $action = $this->createAction($relationName, $relationTemplate, $definition);
                // add a sort value in!
                $action->Sort = $sort++;
                $action->write();

                $actions[$relationName] = $action;

                $newTransitions = $this->updateActionTransitions($relationTemplate, $action);
                foreach ($newTransitions as $t) {
                    $transitions->append($t);
                }
            }
            // Process users on WorkflowDefinition from the template
            if ($isUsers) {
                $this->createUsers($relationTemplate, $definition);
            }
            // Process groups on WorkflowDefinition from the template
            if ($isGroups) {
                $this->createGroups($relationTemplate, $definition);
            }
        }

        foreach ($transitions as $transition) {
            if (isset($actions[$transition->Target])) {
                $transition->NextActionID = $actions[$transition->Target]->ID;
            }
            $transition->write();
        }

        return $actions;
    }
431076
public function addPolicyDefinition(PolicyDefinition $definition)
  {
    // Do not include excluded dependencies
    if (!in_array($definition->getName(), $this->excludedPolicies)) {
      $this->policies[$definition->getName()] = $definition;
    }
    return $this;
  }
645232
@SuppressWarnings({"UnusedDeclaration"})
    protected final void addFilterChain(String pattern, Key<? extends Filter>... keys) {
        filterChains.put(pattern, keys);
    }
1201746
public function addCondition(Filter $filter, $attribute, $partial = false)
    {
        $value = $this->$attribute;

        if (mb_strpos($value, '>') !== false) {
            $value = (int)str_replace('>', '', $value);
            $filter->addMatcher($attribute, new matchers\GreaterThan(['value' => $value]));

        } elseif (mb_strpos($value, '<') !== false) {
            $value = (int)str_replace('<', '', $value);
            $filter->addMatcher($attribute, new matchers\LowerThan(['value' => $value]));
        } else {
            $filter->addMatcher($attribute, new matchers\SameAs(['value' => $value, 'partial' => $partial]));
        }
    }
84238
public function addShape($field, $type, array $coordinates, $relation = self::INTERSECTS, array $parameters = [])
    {
        // TODO: remove this in the next major version
        if (is_array($relation)) {
            $parameters = $relation;
            $relation = self::INTERSECTS;
            trigger_error('$parameters as parameter 4 in addShape is deprecated', E_USER_DEPRECATED);
        }

        $filter = array_merge(
            $parameters,
            [
                'type' => $type,
                'coordinates' => $coordinates,
            ]
        );

        $this->fields[$field] = [
            'shape' => $filter,
            'relation' => $relation,
        ];
    }
786020
protected function addProcessedRelation($key, $value, $type = RelationTypes::PRODUCT_RELATION)
    {
        $this->getSubject()->addProcessedRelation($key, $value, $type);
    }
853054
public void addRelationshipFilter(RelatedFinder relatedFinder, Operation filter)
    {
        Operation existing = this.filters.get(relatedFinder);
        this.filters.put(relatedFinder, existing == null ? filter : existing.or(filter));
    }
1071307
protected function addFilters($type, $filters)
	{
		if (isset($this->action[$type]))
		{
			$this->action[$type] .= '|'.$filters;
		}
		else
		{
			$this->action[$type] = $filters;
		}

		return $this;
	}
109061
public void addFilter(AbstractLogFilter<E> filter) {
                Validate.notNull(filter);
                filters.add(filter);
                uptodate = false;
                filter.addObserver(this);
        }
933692
private function addFilter($value = null, $type, $isNegative, $parameters = array()) {
		if(empty($this->data['filters'])) {
			$this->data['filters'] = array();
		}
    
		$newFilter = array(
			'type' => $type,
			'negative' => (boolean)$isNegative,
		);
		//add options depending on type of filter
		switch($type) {
			case self::GEO_FILTER:
				$newFilter['shape'] = $parammeters['shape'];
				$newFilter['unit'] = $parammeters['unit'];
				$newFilter['distance'] = $parammeters['distance'];
				break;
			case self::QUERY_FILTER:
				$newFilter['query'] = $value;
				break;
			case self::RELATIVE_DATE_FILTER:
			    $newFilter['from'] = array(
			    		'unit' => $parameters['fromUnit'],
			    		'interval' => $parameters['fromInterval'],
			        );
			    $newFilter['to'] = array(
			    		'unit' => $parameters['toUnit'],
			    		'interval' => $parameters['toInterval'],
			        );
			    $newFilter['field'] = $parameters['field'];
			    $newFilter['dateFormat'] = $parameters['dateFormat'];
			    break;
		}
		$this->data['filters'][] = $newFilter;
	}
619738
public function AddFilter(CriteriaFilter $filter)
	{
		if (!$this->Filters) $this->Filters = array();
		$this->Filters[] = $filter;
	}
49453
public function withFilter(Filter $filter)
    {
        if ($this->value->isNull()) {
            return null;
        }

        return $this->applyFilter($filter);
    }
586236
public function addFilter(FilterInterface $filter, $placement = self::CHAIN_APPEND)
    {
        if ($placement == self::CHAIN_PREPEND) {
            array_unshift($this->filters, $filter);
        } else {
            $this->filters[] = $filter;
        }

        return $this;
    }
1121646
public function add_filter($field, $filter) {

		if(!is_callable($filter)) return $this;

		if(!isset($this->filters[$field])) $this->filters[$field] = array();
		$this->filters[$field][] = $filter;

		return $this;

	}