SearchVariant
abstract class SearchVariant (View source)
A Search Variant handles decorators and other situations where the items to reindex or search through are modified from the default state - for instance, dealing with Versioned or Subsite
Properties
protected static | $variants | Holds a cache of all variants |
||
protected static | $class_variants | Holds a cache of the variants keyed by "class!" "1"? (1 = include subclasses) |
||
protected static | $call_instances | Holds a cache of SearchVariant_Caller instances, one for each class/includeSubclasses setting |
Methods
Return false if there is something missing from the environment (probably a not installed module) that means this variant can't apply to any class
Return true if this variant applies to the passed class & subclass
Returns an array of variants.
Lets you call any function on all variants that support it, in the same manner as "Object#extend" calls a method from extensions.
A shortcut to with when calling without passing in a class,
Get the current state of every variant
Return an iterator that, when used in a for loop, activates one combination of reindex states per loop, and restores back to the original state at the end
Add new filter field to index safely.
Merge sets of (or individual) class names together for a search index field.
Details
__construct()
No description
abstract
appliesToEnvironment()
Return false if there is something missing from the environment (probably a not installed module) that means this variant can't apply to any class
abstract
appliesTo($class, $includeSubclasses)
Return true if this variant applies to the passed class & subclass
abstract
currentState()
Return the current state
abstract
reindexStates()
Return all states to step through to reindex all items
abstract
activateState($state)
Activate the passed state
abstract
alterQuery(SearchQuery $query, SearchIndex $index)
Apply this variant to a search query
static array
variants(string $class = null, bool $includeSubclasses = true)
Returns an array of variants.
With no arguments, returns all variants
With a classname as the first argument, returns the variants that apply to that class (optionally including subclasses)
static SearchVariant_Caller
with(string $class = null, bool $includeSubclasses = true)
Lets you call any function on all variants that support it, in the same manner as "Object#extend" calls a method from extensions.
Usage: SearchVariant::with(...)->call($method, $arg1, ...);
static
call($method, $a1 = null, $a2 = null, $a3 = null, $a4 = null, $a5 = null, $a6 = null, $a7 = null)
A shortcut to with when calling without passing in a class,
SearchVariant::call(...) ==== SearchVariant::with()->call(...);
static array
current_state($class = null, $includeSubclasses = true)
Get the current state of every variant
static void
activate_state($state)
Activate all the states in the passed argument
static SearchVariant_ReindexStateIteratorRet
reindex_states(string $class = null, bool $includeSubclasses = true)
Return an iterator that, when used in a for loop, activates one combination of reindex states per loop, and restores back to the original state at the end
protected
addFilterField(SearchIndex $index, string $name, array $field)
Add new filter field to index safely.
This method will respect existing filters with the same field name that correspond to multiple classes
protected array|string
mergeClasses(array|string $left, array|string $right)
Merge sets of (or individual) class names together for a search index field.
If there is only one unique class name, then just return it as a string instead of array.