CoolCMS API

FulltextFilter extends BaseFilter
in package
implements Filter

Table of Contents

Interfaces

Filter

Constants

MODE_BOOLEAN  : mixed = 'boolean'
MODE_EXPANSION  : mixed = 'expansion'
MODE_NATURAL  : mixed = 'natural'

Properties

$applyToCollections  : bool
$fields  : array<string|int, string>
$fromTableAlias  : string|null
$minScore  : float
$mode  : string
$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.
plainTerms()  : string
Words of the text without the boolean-mode operators `+ - < > ( ) ~ * " @`.
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

Constants

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

$phaseOneOnly

protected bool $phaseOneOnly = false

$textTableAlias

protected string|null $textTableAlias = null

Methods

__construct()

public __construct(array<string|int, string>|string $fields, mixed $value[, string $mode = self::MODE_BOOLEAN ][, float $minScore = 0 ][, bool $literal = true ]) : mixed
Parameters
$fields : array<string|int, string>|string
$value : mixed
$mode : string = self::MODE_BOOLEAN
$minScore : float = 0
$literal : bool = true

the value is text typed by a user: in boolean mode its operator characters are removed, otherwise input such as a -- b or <x> is a MySQL syntax error (HTTP 500). false passes the value as boolean syntax (raw Api filter).

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

plainTerms()

Words of the text without the boolean-mode operators `+ - < > ( ) ~ * " @`.

public static plainTerms(string $text) : string
Parameters
$text : string
Return values
string

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|string|null $index = null ]) : string
Parameters
$qb : QueryBuilder
$index : int|string|null = null
Return values
string

sanitizeFieldName()

private sanitizeFieldName(string $field) : string
Parameters
$field : string
Return values
string
On this page

Search results