CoolCMS API

GroupFilter extends BaseFilter
in package
implements Filter

Table of Contents

Interfaces

Filter

Properties

$applyToCollections  : bool
$fields  : array<string|int, string>
$filters  : array<string|int, mixed>
$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.
getFilters()  : array<string|int, Filter>
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.
collectJoinAliases()  : array<string, bool>
Returns the aliases of all joins currently on `$qb`.
collectParameterNames()  : array<string, bool>
Returns the names of the parameters currently bound on `$qb`.
copyNewJoins()  : void
Copies joins created on `$source` (the sub-filter's temporary QB) that are missing on `$target` (the real QB).
copyNewParameters()  : void
Copies parameters the sub-filter bound on `$source` (temporary QB) that are missing on `$target` (real QB).
joinsOf()  : array<int, Join>
Returns the joins of all query roots in the order they were added.
whereParts()  : array<int, Andx|Comparison|Func|Orx|string>
Returns the WHERE parts (Doctrine keeps them as `Andx`/`Orx`; an empty WHERE is null).

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)

$filters read-only

protected array<string|int, mixed> $filters

$fromTableAlias

protected string|null $fromTableAlias = null

$phaseOneOnly

protected bool $phaseOneOnly = false

$textTableAlias

protected string|null $textTableAlias = null

Methods

__construct()

public __construct(array<string|int, Filter> $filters[, string $logic = 'AND' ]) : mixed
Parameters
$filters : array<string|int, Filter>
$logic : string = 'AND'

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
bool

apply()

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|null

getBindings()

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
string

getType()

Returns the filter type/operator (e.g. '=', 'LIKE', 'IN').

public getType() : string
Return values
string

getValue()

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
bool

setApplyToCollections()

public setApplyToCollections([bool $applyToCollections = true ]) : static
Parameters
$applyToCollections : bool = true
Return values
static

setFields()

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
static

setFromTableAlias()

Sets the alias of the main table for join operations.

public final setFromTableAlias(string|null $alias) : static
Parameters
$alias : string|null
Return values
static

setPhaseOneOnly()

public setPhaseOneOnly([bool $phaseOneOnly = true ]) : static
Parameters
$phaseOneOnly : bool = true
Return values
static

setTextTableAlias()

Sets the alias of the text (translations) table for join operations.

public final setTextTableAlias(string|null $alias) : static
Parameters
$alias : string|null
Return values
static

toSql()

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
string

collectJoinAliases()

Returns the aliases of all joins currently on `$qb`.

private collectJoinAliases(QueryBuilder $qb) : array<string, bool>
Parameters
$qb : QueryBuilder
Return values
array<string, bool> —

alias mapped to true

collectParameterNames()

Returns the names of the parameters currently bound on `$qb`.

private collectParameterNames(QueryBuilder $qb) : array<string, bool>
Parameters
$qb : QueryBuilder
Return values
array<string, bool> —

parameter name mapped to true

copyNewJoins()

Copies joins created on `$source` (the sub-filter's temporary QB) that are missing on `$target` (the real QB).

private copyNewJoins(QueryBuilder $source, QueryBuilder $target, array<string, bool> &$existingJoinAliases) : void

Deduplication is by join alias and $existingJoinAliases is updated as it goes, so several consecutive sub-filters do not add the same join twice.

Parameters
$source : QueryBuilder
$target : QueryBuilder
$existingJoinAliases : array<string, bool>

copyNewParameters()

Copies parameters the sub-filter bound on `$source` (temporary QB) that are missing on `$target` (real QB).

private copyNewParameters(QueryBuilder $source, QueryBuilder $target, array<string, bool> $before) : void

Sub-filter parameter names are unique (they contain the group index and the sub-filter order), so they cannot collide with parameters of the outer query.

Parameters
$source : QueryBuilder
$target : QueryBuilder
$before : array<string, bool>

parameter names before the sub-filter was applied

joinsOf()

Returns the joins of all query roots in the order they were added.

private joinsOf(QueryBuilder $qb) : array<int, Join>
Parameters
$qb : QueryBuilder
Return values
array<int, Join>

whereParts()

Returns the WHERE parts (Doctrine keeps them as `Andx`/`Orx`; an empty WHERE is null).

private whereParts(QueryBuilder $qb) : array<int, Andx|Comparison|Func|Orx|string>
Parameters
$qb : QueryBuilder
Return values
array<int, Andx|Comparison|Func|Orx|string>
On this page

Search results