EqualFilter
extends BaseFilter
in package
implements
Filter
Table of Contents
Interfaces
Properties
- $applyToCollections : bool
- $fields : array<string|int, string>
- $fromTableAlias : string|null
- $operator : string
- $phaseOneOnly : bool
- $textTableAlias : string|null
- $value : mixed
Methods
- __construct() : mixed
- appliesToCollections() : bool
- Tells whether the filter also applies to ToMany branch queries (phase 2 of hydration).
- apply() : void
- Applies the filter to the Doctrine QueryBuilder.
- applyWithCondition() : string|null
- Default implementation for simple operators (`=`, `!=`, `<`, `<=`, `>`, `>=`, `LIKE`, `NOT LIKE`).
- getBindings() : ArrayCollection<int, Parameter>
- Returns the filter's parameter bindings.
- getFields() : array<string|int, string>
- Returns the field or fields the filter applies to.
- getOperator() : string
- getType() : string
- Returns the filter type/operator (e.g. '=', 'LIKE', 'IN').
- getValue() : mixed
- Returns the filter value.
- isPhaseOneOnly() : bool
- When true, the filter applies only to phase 1 (root ID selection) and does not leak into the ToMany branch queries of the second hydration phase.
- setApplyToCollections() : static
- setFields() : static
- Sets the field or fields the filter applies to.
- setFromTableAlias() : static
- Sets the alias of the main table for join operations.
- setPhaseOneOnly() : static
- setTextTableAlias() : static
- Sets the alias of the text (translations) table for join operations.
- toSql() : string
- Builds the SQL condition for the filter.
- sanitizeFieldName() : string
Properties
$applyToCollections
protected
bool
$applyToCollections
= false
$fields
protected
array<string|int, string>
$fields
field names; always an array, even when a single name was passed (the constructor and setFields() normalize it)
$fromTableAlias
protected
string|null
$fromTableAlias
= null
$operator
protected
string
$operator
$phaseOneOnly
protected
bool
$phaseOneOnly
= false
$textTableAlias
protected
string|null
$textTableAlias
= null
$value
protected
mixed
$value
Methods
__construct()
public
__construct(array<string|int, string>|string $fields, mixed $value[, string $operator = '=' ]) : mixed
Parameters
- $fields : array<string|int, string>|string
- $value : mixed
- $operator : string = '='
appliesToCollections()
Tells whether the filter also applies to ToMany branch queries (phase 2 of hydration).
public
appliesToCollections() : bool
The filter decides which parents are returned (phase 1); includes decide what is
loaded for them, and always in full. A dotted filter is therefore not propagated to the
branch query (OrmRepository::filtersForBranch()):
otherwise the collection would be silently trimmed to the matching subset and an
object-graph save would INSERT the unmatched children again (UNIQUE violation, the
save works only the first time).
setApplyToCollections(true) is an explicit opt-in for the rare caller that really wants
the trimmed collection (e.g. orders loaded only with items X); such a caller must not
save anything through it afterwards.
Return values
boolapply()
Applies the filter to the Doctrine QueryBuilder.
public
apply(QueryBuilder $qb, int|string $index) : void
Parameters
- $qb : QueryBuilder
- $index : int|string
applyWithCondition()
Default implementation for simple operators (`=`, `!=`, `<`, `<=`, `>`, `>=`, `LIKE`, `NOT LIKE`).
public
applyWithCondition(QueryBuilder $qb, string $joinAlias, string $column, int &$paramIndex) : string|null
Special filters (IS NULL, IN, BETWEEN, RANGE) override this method.
Parameters
- $qb : QueryBuilder
- $joinAlias : string
- $column : string
- $paramIndex : int
-
parameter counter passed by reference (incremented inside)
Return values
string|nullgetBindings()
Returns the filter's parameter bindings.
public
getBindings([string|int|null $index = null ]) : ArrayCollection<int, Parameter>
Parameters
- $index : string|int|null = null
Return values
ArrayCollection<int, Parameter>getFields()
Returns the field or fields the filter applies to.
public
getFields() : array<string|int, string>
Return values
array<string|int, string>getOperator()
public
getOperator() : string
Return values
stringgetType()
Returns the filter type/operator (e.g. '=', 'LIKE', 'IN').
public
getType() : string
Return values
stringgetValue()
Returns the filter value.
public
getValue() : mixed
isPhaseOneOnly()
When true, the filter applies only to phase 1 (root ID selection) and does not leak into the ToMany branch queries of the second hydration phase.
public
isPhaseOneOnly() : bool
Use case: searching adverts by a single parameter — find adverts that have that parameter, but in the detail load all of their parameters, not just the filtered one.
Return values
boolsetApplyToCollections()
public
setApplyToCollections([bool $applyToCollections = true ]) : static
Parameters
- $applyToCollections : bool = true
Return values
staticsetFields()
Sets the field or fields the filter applies to.
public
setFields(array<string|int, string>|string $fields) : static
Parameters
- $fields : array<string|int, string>|string
Return values
staticsetFromTableAlias()
Sets the alias of the main table for join operations.
public
final setFromTableAlias(string|null $alias) : static
Parameters
- $alias : string|null
Return values
staticsetPhaseOneOnly()
public
setPhaseOneOnly([bool $phaseOneOnly = true ]) : static
Parameters
- $phaseOneOnly : bool = true
Return values
staticsetTextTableAlias()
Sets the alias of the text (translations) table for join operations.
public
final setTextTableAlias(string|null $alias) : static
Parameters
- $alias : string|null
Return values
statictoSql()
Builds the SQL condition for the filter.
public
toSql(QueryBuilder $qb[, int|null $index = null ]) : string
Parameters
- $qb : QueryBuilder
- $index : int|null = null
Return values
stringsanitizeFieldName()
private
sanitizeFieldName(string $field) : string
Parameters
- $field : string