FilteredScopeTrait uses trait:short
Builds the **filtered scope** shared by every list-family query: the `FOR` segment (over the View or the collection) and the conjunctive `FILTER` clause.
list(), count(), the facet counts and the bounds all iterate the same set
— so their FOR + FILTER must be built identically, or the numbers would
disagree (a facet bucket or a bound framing a set the list never shows). This
trait is the single source of that construction.
When an active View search is present (AQL::VIEW declaration + a ?search
term), the FOR iterates the View with an index-accelerated SEARCH segment
and the search leaves the FILTER; otherwise the classic collection FOR
with the LIKE sweep in the FILTER is kept. The collection (or the View) is
bound only on its own branch — an unused bind variable would be rejected by
the server.
The collection FOR carries the index the model hands the optimizer
(AQL::INDEX_HINT, IndexHintTrait) — the View FOR never does : a View
knows no indexHint.
The trait assumes a host that provides the filtering fragments it composes
(prepareViewSearch(), prepareActive(), prepareFacets(), prepareFilter(),
prepareSearch(), bindView(), bindCollection() and the $conditions
property) — the same host contract as FacetCountsQueryTrait /
BoundsQueryTrait. In practice it is composed by every *QueryTrait of
the list family.
Tags
Table of Contents
Properties
- $forceIndexHint : bool|null
- Whether the {@see $indexHint} is mandatory. `null` leaves the server's default (`false`).
- $indexHint : string|array<int, string>|null
- The index the loop is handed : a name, or a list of names in order of preference. `null` — the default — hands none.
Methods
- initializeIndexHint() : $this
- Initialize the index handed to the optimizer, and whether it is mandatory.
- buildFilteredScope() : array{0: string, 1: ?string}
- Builds the `FOR` segment and the conjunctive `FILTER` clause shared by the list-family queries.
- indexHintOptions() : array<string, mixed>|null
- The options of the loop over the collection, or null when no index is handed.
Properties
$forceIndexHint
Whether the {@see $indexHint} is mandatory. `null` leaves the server's default (`false`).
public
bool|null
$forceIndexHint
= null
$indexHint
The index the loop is handed : a name, or a list of names in order of preference. `null` — the default — hands none.
public
string|array<int, string>|null
$indexHint
= null
Methods
initializeIndexHint()
Initialize the index handed to the optimizer, and whether it is mandatory.
public
initializeIndexHint([array<string|int, mixed> $init = [] ]) : $this
Parameters
- $init : array<string|int, mixed> = []
-
Reads
AQL::INDEX_HINTandAQL::FORCE_INDEX_HINT.
Return values
$thisbuildFilteredScope()
Builds the `FOR` segment and the conjunctive `FILTER` clause shared by the list-family queries.
protected
buildFilteredScope([array<string|int, mixed> $init = [] ][, array<string|int, mixed> &$bindVars = [] ][, bool $forcible = false ]) : array{0: string, 1: ?string}
Parameters
- $init : array<string|int, mixed> = []
-
The query options.
- $bindVars : array<string|int, mixed> = []
-
The bind variables, populated by reference.
- $forcible : bool = false
-
Whether the declared hint may be FORCED on this loop : the list passes
true, its count, facet counts and bounds keep the default — see IndexHintTrait.
Tags
Return values
array{0: string, 1: ?string} —The [ $for, $filter ] pair.
indexHintOptions()
The options of the loop over the collection, or null when no index is handed.
protected
indexHintOptions([bool $forcible = true ]) : array<string, mixed>|null
⚠️ forceIndexHint alone, without an index to force, hands nothing.
Parameters
- $forcible : bool = true
-
Whether this loop may carry
forceIndexHint— the list's does, the loops that sort nothing do not.